<?php
namespace Home\Controller;
use Think\Controller;
class RankingController extends BaseController {
    /*考核人员分数列表*/

	//列表页
    public function score_list(){
		if(IS_POST){
			// var_dump($_POST);die;
			$map1['posts'] = $_POST['p_id'];
			$notes_id = $_POST['notes_id'];
			$notes = M('notes')->where('id='.$notes_id)->find();
			$map['test_time'] = $notes['ktime'];
			$map1['ktime'] = date("Y",$notes['ktime']);
			// 搜索
			$where = array();
			$search=$_POST['search'];
			$fields=M('worker')->getDbFields();
			// var_dump($fields);die;
			foreach($fields as $key=>$val)
			{
				if(strpos($val,'name')!==false || strpos($val,'info')!==false )
					$where[$val]=array('like','%'.$search.'%');

			}
			// var_dump($where);die;
			$wor = M('worker')->where($where)->select();
			// echo "<pre>";
			// var_dump($wor);
			// echo "</pre>";die;
			foreach($wor as $key => $val){
				$wids[] = $val['worker_id'];
			}
			// 获取该岗位下的分档信息
			$class = M('class')->where($map1)->select();
			// var_dump($class);die;
			foreach($wids as $key4 => $val4){
				$list[] = M('score')->where('worker_id='.$val4)->where($map)->find();
				foreach($list as $key5 => $val5){
					$score[] = $val5['sum'];
					// var_dump($score);die;
					foreach($score as $key6 => $val6){
						if($val6 >= $class['0']['bottom'] && $val6 < $class['0']['top']){
							$list[$key5]['dang'] = '优秀';
						}elseif($val6 >= $class['1']['bottom'] && $val6 < $class['1']['top']){
							$list[$key5]['dang'] = '良好';
						}elseif($val6 >= $class['2']['bottom'] && $val6 < $class['2']['top']){
							$list[$key5]['dang'] = '一般';
						}elseif($val6 >= $class['3']['bottom'] && $val6 < $class['3']['top']){
							$list[$key5]['dang'] = '差';
						}
					}
				}

			}
			// var_dump($list);die;
			$sums = array();
			foreach($list as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$list);
			$posts = M('posts')->where('parent_id = 0')->select();
			$note = M('notes')->order('ktime desc')->select();
			$count = count($list);
			$this->assign('posts',$posts);
			// $this->assign('pos',$pos);
			$this->assign('score',$list);
			$this->assign('notes',$note);
			$this->assign('count',$count);
			// $this->assign('notes_id',$notes_id);
			$this->display();

		}else{
			$notes10 = M('notes')->order('ktime desc')->select();
			// var_dump($notes);die;
			if(empty($notes10)){
				$this->error('无考核人员，请添加考核表！',U('notes/add_notes'));
			}else{
				$posts10 = M('posts')->where('parent_id = 0')->order('posts_id asc')->select();
				$pos10 = $posts10['0']['posts_id']; // 岗位ID
				$po10 = M('posts')->where('parent_id='.$pos10)->select();
				foreach($po10 as $key => $val){
					$cp[] = $val['posts_id'];
				}
				$map['posts_id'] = array('in',$cp);
				$map['test_time'] = $notes10['0']['ktime'];
				$list10 = M('score')->where($map)->select();
				// echo "<pre>";
				// var_dump($list);
				// echo "</pre>";die;
				// 获取该岗位下的分档信息
				$map1['posts'] = $pos10;
				$map1['ktime'] = date("Y",$notes10['0']['ktime']);
				$class = M('class')->where($map1)->select();
				// var_dump($class);die;
				foreach($list10 as $key => $val){
					if($val['sum'] >= $class['0']['bottom'] && $val['sum'] < $class['0']['top']){
						$list10[$key]['dang'] = '优秀';
					}elseif($val['sum'] >= $class['1']['bottom'] && $val['sum'] < $class['1']['top']){
						$list10[$key]['dang'] = '良好';
					}elseif($val['sum'] >= $class['2']['bottom'] && $val['sum'] < $class['2']['top']){
						$list10[$key]['dang'] = '一般';
					}elseif($val['sum'] >= $class['3']['bottom'] && $val['sum'] < $class['3']['top']){
						$list10[$key]['dang'] = '差';
					}
				}
				// 排序
				$sums = array();
				foreach($list10 as $li){
					$sums[] = $li['sum'];
				}
				array_multisort($sums,SORT_DESC,$list10);
				// echo "<pre>";
				// var_dump($list);
				// echo "</pre>";die;
				$count10 = count($list10);

                $this->assign('posts10',$posts10);
    			$this->assign('pos10',$pos10);
    			$this->assign('cposts10',$po10);
    			$this->assign('score10',$list10);
    			$this->assign('notes10',$notes10);
    			$this->assign('count10',$count10);
    			$this->assign('notes_id10',$notes10['0']['id']);
    			$this->display();		
				// $this->assign('posts',$posts);
				// $this->assign('pos',$pos);
				// $this->assign('cposts',$po);
				// $this->assign('score',$list);
				// $this->assign('notes',$notes);
				// $this->assign('count',$count);
				// $this->assign('notes_id',$notes['0']['id']);
				// $this->display();
			}
		}
	}

	public function score_analysis(){
        $score = M('score')->select();
        if(!empty($score)){
            $notes = M('notes')->order('ktime desc')->select();
            $ktime = $notes['0']['ktime'];
            $ktime1 = date("Y",$ktime);
            $score = M('score')->where('test_time='.$ktime)->select();
            if(empty($score)){
                $ktime = $notes['1']['ktime'];
                $ktime1 = date("Y",$ktime);
                $score = M('score')->where('test_time='.$ktime)->select();
                $count = count($score); // 最新考核表下的所有人
                $posts = M('posts')->where('parent_id=0')->order('posts_id asc')->select();
            // 板块一 开始
                // 员额法官
                $posts0 = M('posts')->where('parent_id='.$posts['0']['posts_id'])->select();
                foreach($posts0 as $k0 => $v0){
                    $posts00[] = $v0['posts_id'];
                }
                $map0['posts_id'] = array('in',$posts00);
                $map0['test_time'] = $ktime;
                $score0 = M('score')->where($map0)->select();
                // var_dump($score0);die;
                $count0 = count($score0);
                $mp0['ktime'] = $ktime1;
                $mp0['posts'] = $posts['0']['posts_id'];
                $class0 = M('class')->where($mp0)->order('class_id asc')->select();
                foreach($score0 as $key0 => $val0){
                    if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
                        $sum01[] = $val0['sum'];
                        $count01 = count($sum01);
                        $bfb = $count01 / $count0 * '100%';
                        $bfb01 = round($bfb,2);
                    }elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
                        $sum02[] = $val0['sum'];
                        $count02 = count($sum02);
                        $bfb = $count02 / $count0 * '100%';
                        $bfb02 = round($bfb,2);
                    }elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
                        $sum03[] = $val0['sum'];
                        $count03 = count($sum03);
                        $bfb = $count03 / $count0 * '100%';
                        $bfb03 = round($bfb,2);
                    }elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
                        $sum04[] = $val0['sum'];
                        $count04 = count($sum04);
                        $bfb = $count04 / $count0 * '100%';
                        $bfb04 = round($bfb,2);
                    }
                }
                if(empty($bfb01)){
                    $bfb01 = 0;
                }
                if(empty($bfb02)){
                    $bfb02 = 0;
                }
                if(empty($bfb03)){
                    $bfb03 = 0;
                }
                if(empty($bfb04)){
                    $bfb04 = 0;
                }
                $list0['0'] = $bfb01;
                $list0['1'] = $bfb02;
                $list0['2'] = $bfb03;
                $list0['3'] = $bfb04;
                // var_dump($list0);die;

                // 司法行政人员
                $posts1 = M('posts')->where('parent_id='.$posts['1']['posts_id'])->select();
                foreach($posts1 as $k1 => $v1){
                    $posts11[] = $v1['posts_id'];
                }
                $map1['posts_id'] = array('in',$posts11);
                $map1['test_time'] = $ktime;
                $score1 = M('score')->where($map1)->select();
                $count1 = count($score1);
                $mp1['ktime'] = $ktime1;
                $mp1['posts'] = $posts['1']['posts_id'];
                $class1 = M('class')->where($mp1)->order('class_id asc')->select();
                foreach($score1 as $key1 => $val1){
                    if($val1['sum'] >= $class1['0']['bottom'] && $val1['sum'] < $class1['0']['top']){
                        $sum11[] = $val1['sum'];
                        $count11 = count($sum11);
                        $bfb = $count11 / $count1 * '100%';
                        $bfb11 = round($bfb,2);
                    }elseif($val1['sum'] >= $class1['1']['bottom'] && $val1['sum'] < $class1['1']['top']){
                        $sum12[] = $val1['sum'];
                        $count12 = count($sum12);
                        $bfb = $count12 / $count1 * '100%';
                        $bfb12 = round($bfb,2);
                    }elseif($val1['sum'] >= $class1['2']['bottom'] && $val1['sum'] < $class1['2']['top']){
                        $sum13[] = $val1['sum'];
                        $count13 = count($sum13);
                        $bfb = $count13 / $count1 * '100%';
                        $bfb13 = round($bfb,2);
                    }elseif($val1['sum'] >= $class1['3']['bottom'] && $val1['sum'] < $class1['3']['top']){
                        $sum14[] = $val1['sum'];
                        $count14 = count($sum14);
                        $bfb = $count14 / $count1 * '100%';
                        $bfb14 = round($bfb,2);
                    }
                }
                if(empty($bfb11)){
                    $bfb11 = 0;
                }
                if(empty($bfb12)){
                    $bfb12 = 0;
                }
                if(empty($bfb13)){
                    $bfb13 = 0;
                }
                if(empty($bfb14)){
                    $bfb14 = 0;
                }
                $list1['0'] = $bfb11;
                $list1['1'] = $bfb12;
                $list1['2'] = $bfb13;
                $list1['3'] = $bfb14;

                // 司法辅助人员
                $posts2 = M('posts')->where('parent_id='.$posts['2']['posts_id'])->select();
                foreach($posts2 as $k2 => $v2){
                    $posts22[] = $v2['posts_id'];
                }
                $map2['posts_id'] = array('in',$posts22);
                $map2['test_time'] = $ktime;
                $score2 = M('score')->where($map2)->select();
                $count2 = count($score2);
                $mp2['ktime'] = $ktime1;
                $mp2['posts'] = $posts['2']['posts_id'];
                $class2 = M('class')->where($mp2)->order('class_id asc')->select();
                foreach($score2 as $key2 => $val2){
                    if($val2['sum'] >= $class2['0']['bottom'] && $val2['sum'] < $class2['0']['top']){
                        $sum21[] = $val2['sum'];
                        $count21 = count($sum21);
                        $bfb = $count21 / $count2 * '100%';
                        $bfb21 = round($bfb,2);
                    }elseif($val2['sum'] >= $class2['1']['bottom'] && $val2['sum'] < $class2['1']['top']){
                        $sum22[] = $val2['sum'];
                        $count22 = count($sum22);
                        $bfb = $count22 / $count2 * '100%';
                        $bfb22 = round($bfb,2);
                    }elseif($val2['sum'] >= $class2['2']['bottom'] && $val2['sum'] < $class2['2']['top']){
                        $sum23[] = $val2['sum'];
                        $count23 = count($sum23);
                        $bfb = $count23 / $count2 * '100%';
                        $bfb23 = round($bfb,2);
                    }elseif($val2['sum'] >= $class2['3']['bottom'] && $val2['sum'] < $class2['3']['top']){
                        $sum24[] = $val2['sum'];
                        $count24 = count($sum24);
                        $bfb = $count24 / $count2 * '100%';
                        $bfb24 = round($bfb,2);
                    }
                }
                if(empty($bfb21)){
                    $bfb21 = 0;
                }
                if(empty($bfb22)){
                    $bfb22 = 0;
                }
                if(empty($bfb23)){
                    $bfb23 = 0;
                }
                if(empty($bfb24)){
                    $bfb24 = 0;
                }
                $list2['0'] = $bfb21;
                $list2['1'] = $bfb22;
                $list2['2'] = $bfb23;
                $list2['3'] = $bfb24;
                // 所有人分析
                $num1 = $count01 + $count11 + $count21;
                $bf1 = $num1 / $count * '100%';
                $bfb1 = round($bf1,2);
                $num2 = $count02 + $count12 + $count22;
                $bf2 = $num2 / $count * '100%';
                $bfb2 = round($bf2,2);
                $num3 = $count03 + $count13 + $count23;
                $bf3 = $num3 / $count * '100%';
                $bfb3 = round($bf3,2);
                $num4 = $count04 + $count14 + $count24;
                $bf4 = $num4 / $count * '100%';
                $bfb4 = round($bf4,2);
                if(empty($bfb1)){
                    $bfb1 = 0;
                }
                if(empty($bfb2)){
                    $bfb2 = 0;
                }
                if(empty($bfb3)){
                    $bfb3 = 0;
                }
                if(empty($bfb4)){
                    $bfb4 = 0;
                }
                $list['0'] = $bfb1;
                $list['1'] = $bfb2;
                $list['2'] = $bfb3;
                $list['3'] = $bfb4;
                $list0 = implode(',',$list0);
                $list1 = implode(',',$list1);
                $list2 = implode(',',$list2);
                $list = implode(',',$list);
            // 板块一 结束

            // 板块二 开始
                // 一月 开始 
                $ktime2 = $ktime1 . '-' . '01'; // 考核年月
                $ktime3 = strtotime($ktime2); // 考核年月时间戳 一月
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where0['ktime'] = $ktime;
                $where0['mtime'] = $ktime3;
                $where0['score_id'] = array('in',$yuan_id);
                $where01['ktime'] = $ktime;
                $where01['mtime'] = $ktime2;
                $where01['score_id'] = array('in',$yuan_id);
                $detail = M('detail')->where($where0)->select();
                $entry = M('entry')->where($where01)->select();
                if(empty($detail) && empty($entry)){
                    // 默认值
                    $ycount0 = count($score0);
                    $ysum0 = $ycount0 * 90;
                    $pyuan01 = $ysum0 / $ycount0;
                }else{
                    if(empty($detail)){
                        // 计算entry表中的数据
                        foreach($entry as $key31 => $value31){
                            $entry01[] = $value31['score'];
                        }
                        $cha01 = array_sum($entry01);
                        $ycount0 = count($score0);
                        $ysum0 = $ycount0 * 90 + $cha01;
                        $pyuan01 = round($ysum0 / $ycount0,2);
                    }elseif(empty($entry)){
                        // 计算detail表中的数据
                        foreach($detail as $key32 => $value32){
                            $detail01[] = $value32['score'];
                        }
                        $cha01 = array_sum($detail01);
                        $ycount0 = count($score0);
                        $ysum0 = $ycount0 * 90 + $cha01;
                        $pyuan01 = round($ysum0 / $ycount0,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail as $key33 => $value33){
                            $detail01[] = $value33['score'];
                        }
                        foreach($entry as $key33 => $value33){
                            $entry01[] = $value33['score'];
                        }
                        $chaz011 = array_sum($detail01);
                        $chaz012 = array_sum($entry01);
                        $cha01 = $chaz011 + $chaz012;
                        $ycount0 = count($score0);
                        $ysum0 = $ycount0 * 90 + $cha01;
                        $pyuan01 = round($ysum0 / $ycount0,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where1['ktime'] = $ktime;
                $where1['mtime'] = $ktime3;
                $where1['score_id'] = array('in',$xinz_id);
                $where11['ktime'] = $ktime;
                $where11['mtime'] = $ktime2;
                $where11['score_id'] = array('in',$xinz_id);
                $detail1 = M('detail')->where($where1)->select();
                $entry1 = M('entry')->where($where11)->select();
                if(empty($detail1) && empty($entry1)){
                    // 默认值
                    $xcount1 = count($score1);
                    $xsum1 = $xcount1 * 90;
                    $pxinz11 = $xsum1 / $xcount1;
                }else{
                    if(empty($detail1)){
                        // 计算entry表中的数据
                        foreach($entry1 as $key41 => $value41){
                            $entry11[] = $value41['score'];
                        }
                        $cha11 = array_sum($entry11);
                        $xcount1 = count($score1);
                        $xsum1 = $xcount1 * 90 + $cha11;
                        $pxinz11 = round($xsum1 / $xcount1,2);
                    }elseif(empty($entry1)){
                        // 计算detail表中的数据
                        foreach($detail1 as $key42 => $value42){
                            $detail11[] = $value42['score'];
                        }
                        $cha11 = array_sum($detail11);
                        $xcount1 = count($score1);
                        $xsum1 = $xcount1 * 90 + $cha11;
                        $pxinz11 = round($xsum1 / $xcount1,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail1 as $key43 => $value43){
                            $detail11[] = $value43['score'];
                        }
                        foreach($entry1 as $key43 => $value43){
                            $entry11[] = $value43['score'];
                        }
                        $chaz111 = array_sum($detail11);
                        $chaz112 = array_sum($entry11);
                        $cha11 = $chaz111 + $chaz112;
                        $xcount1 = count($score1);
                        $xsum1 = $xcount1 * 90 + $cha11;
                        $pxinz11 = round($xsum1 / $xcount1,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where2['ktime'] = $ktime;
                $where2['mtime'] = $ktime3;
                $where2['score_id'] = array('in',$fuz_id);
                $where21['ktime'] = $ktime;
                $where21['mtime'] = $ktime2;
                $where21['score_id'] = array('in',$fuz_id);
                $detail2 = M('detail')->where($where2)->select();
                $entry2 = M('entry')->where($where21)->select();
                if(empty($detail2) && empty($entry2)){
                    // 默认值
                    $fcount2 = count($score2);
                    $fsum2 = $fcount2 * 90;
                    $pfuz22 = $fsum2 / $fcount2;
                }else{
                    if(empty($detail2)){
                        // 计算entry表中的数据
                        foreach($entry2 as $key51 => $value51){
                            $entry22[] = $value51['score'];
                        }
                        $cha21 = array_sum($entry22);
                        $fcount2 = count($score2);
                        $fsum2 = $fcount2 * 90 + $cha21;
                        $pfuz22 = round($fsum2 / $fcount2,2);
                    }elseif(empty($entry2)){
                        // 计算detail表中的数据
                        foreach($detail2 as $key52 => $value52){
                            $detail22[] = $value52['score'];
                        }
                        $cha22 = array_sum($detail22);
                        $fcount2 = count($score2);
                        $fsum2 = $fcount2 * 90 + $cha22;
                        $pfuz22 = round($fsum2 / $fcount2,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail2 as $key53 => $value53){
                            $detail22[] = $value53['score'];
                        }
                        foreach($entry2 as $key53 => $value53){
                            $entry22[] = $value53['score'];
                        }
                        $chaz211 = array_sum($detail22);
                        $chaz212 = array_sum($entry22);
                        $cha22 = $chaz211 + $chaz212;
                        $fcount2 = count($score2);
                        $fsum2 = $fcount2 * 90 + $cha22;
                        $pfuz22 = round($fsum2 / $fcount2,2);
                    }
                }
                // 一月 结束
                $yuan['0'] = $pyuan01;
                $xinz['0'] = $pxinz11;
                $fuz['0'] = $pfuz22;

                // 二月 开始
                for($i = 1;$i <= 2;$i++){
                    $a[] = $i;
                }
                foreach($a as $k => $v){
                    $ktime4[] = $ktime1 . '-0' . $v;
                    $ktime5[] = strtotime($ktime1 . '-' . $v);
                }
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where2['ktime'] = $ktime;
                $where2['mtime'] = array('in',$ktime5);
                $where2['score_id'] = array('in',$yuan_id);
                $where21['ktime'] = $ktime;
                $where21['mtime'] = array('in',$ktime4);
                $where21['score_id'] = array('in',$yuan_id);
                $detail2 = M('detail')->where($where2)->select();
                $entry2 = M('entry')->where($where21)->select();
                if(empty($detail2) && empty($entry2)){
                    // 默认值
                    $ycount2 = count($score0);
                    $ysum2 = $ycount2 * 90;
                    $pyuan21 = $ysum2 / $ycount2;
                }else{
                    if(empty($detail2)){
                        // 计算entry表中的数据
                        foreach($entry2 as $key31 => $value31){
                            $entry21[] = $value31['score'];
                        }
                        $cha21 = array_sum($entry21);
                        $ycount2 = count($score0);
                        $ysum2 = $ycount2 * 90 + $cha21;
                        $pyuan21 = round($ysum2 / $ycount2,2);
                    }elseif(empty($entry2)){
                        // 计算detail表中的数据
                        foreach($detail2 as $key32 => $value32){
                            $detail21[] = $value32['score'];
                        }
                        $cha21 = array_sum($detail21);
                        $ycount2 = count($score0);
                        $ysum2 = $ycount2 * 90 + $cha21;
                        $pyuan21 = round($ysum2 / $ycount2,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail2 as $key33 => $value33){
                            $detail21[] = $value33['score'];
                        }
                        foreach($entry2 as $key33 => $value33){
                            $entry21[] = $value33['score'];
                        }
                        $chaz211 = array_sum($detail21);
                        $chaz212 = array_sum($entry21);
                        $cha21 = $chaz211 + $chaz212;
                        $ycount2 = count($score0);
                        $ysum2 = $ycount2 * 90 + $cha21;
                        $pyuan21 = round($ysum2 / $ycount2,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where22['ktime'] = $ktime;
                $where22['mtime'] = array('in',$ktime5);
                $where22['score_id'] = array('in',$xinz_id);
                $where23['ktime'] = $ktime;
                $where23['mtime'] = array('in',$ktime4);
                $where23['score_id'] = array('in',$xinz_id);
                $detail21 = M('detail')->where($where22)->select();
                $entry21 = M('entry')->where($where23)->select();
                if(empty($detail21) && empty($entry21)){
                    // 默认值
                    $xcount21 = count($score1);
                    $xsum21 = $xcount21 * 90;
                    $pxinz21 = $xsum21 / $xcount21;
                }else{
                    if(empty($detail21)){
                        // 计算entry表中的数据
                        foreach($entry21 as $key41 => $value41){
                            $entry22[] = $value41['score'];
                        }
                        $cha21 = array_sum($entry22);
                        $xcount21 = count($score1);
                        $xsum21 = $xcount21 * 90 + $cha21;
                        $pxinz21 = round($xsum21 / $xcount21,2);
                    }elseif(empty($entry21)){
                        // 计算detail表中的数据
                        foreach($detail21 as $key42 => $value42){
                            $detail22[] = $value42['score'];
                        }
                        $cha22 = array_sum($detail22);
                        $xcount21 = count($score1);
                        $xsum21 = $xcount21 * 90 + $cha22;
                        $pxinz21 = round($xsum21 / $xcount21,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail21 as $key43 => $value43){
                            $detail22[] = $value43['score'];
                        }
                        foreach($entry21 as $key43 => $value43){
                            $entry22[] = $value43['score'];
                        }
                        $chaz211 = array_sum($detail22);
                        $chaz212 = array_sum($entry22);
                        $cha22 = $chaz211 + $chaz212;
                        $xcount21 = count($score1);
                        $xsum21 = $xcount21 * 90 + $cha22;
                        $pxinz21 = round($xsum21 / $xcount21,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where24['ktime'] = $ktime;
                $where24['mtime'] = array('in',$ktime5);
                $where24['score_id'] = array('in',$fuz_id);
                $where25['ktime'] = $ktime;
                $where25['mtime'] = array('in',$ktime4);
                $where25['score_id'] = array('in',$fuz_id);
                $detail22 = M('detail')->where($where24)->select();
                $entry22 = M('entry')->where($where25)->select();
                if(empty($detail22) && empty($entry22)){
                    // 默认值
                    $fcount22 = count($score2);
                    $fsum22 = $fcount22 * 90;
                    $pfuz22 = $fsum22 / $fcount22;
                }else{
                    if(empty($detail22)){
                        // 计算entry表中的数据
                        foreach($entry22 as $key51 => $value51){
                            $entry23[] = $value51['score'];
                        }
                        $cha22 = array_sum($entry23);
                        $fcount22 = count($score2);
                        $fsum22 = $fcount22 * 90 + $cha22;
                        $pfuz22 = round($fsum22 / $fcount22,2);
                    }elseif(empty($entry22)){
                        // 计算detail表中的数据
                        foreach($detail22 as $key52 => $value52){
                            $detail23[] = $value52['score'];
                        }
                        $cha22 = array_sum($detail23);
                        $fcount22 = count($score2);
                        $fsum22 = $fcount22 * 90 + $cha22;
                        $pfuz22 = round($fsum22 / $fcount22,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail22 as $key53 => $value53){
                            $detail23[] = $value53['score'];
                        }
                        foreach($entry22 as $key53 => $value53){
                            $entry23[] = $value53['score'];
                        }
                        $chaz221 = array_sum($detail23);
                        $chaz222 = array_sum($entry23);
                        $cha22 = $chaz221 + $chaz222;
                        $fcount22 = count($score2);
                        $fsum22 = $fcount22 * 90 + $cha22;
                        $pfuz22 = round($fsum22 / $fcount22,2);
                    }
                }
                // 二月 结束
                $yuan['1'] = $pyuan21;
                $xinz['1'] = $pxinz21;
                $fuz['1'] = $pfuz22;
                
                // 三月 开始
                for($i = 1;$i <= 3;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime6[] = $ktime1 . '-0' . $v;
                    $ktime7[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where30['ktime'] = $ktime;
                $where30['mtime'] = array('in',$ktime7);
                $where30['score_id'] = array('in',$yuan_id);
                $where31['ktime'] = $ktime;
                $where31['mtime'] = array('in',$ktime6);
                $where31['score_id'] = array('in',$yuan_id);
                $detail3 = M('detail')->where($where30)->select();
                $entry3 = M('entry')->where($where31)->select();
                if(empty($detail3) && empty($entry3)){
                    // 默认值
                    $ycount3 = count($score0);
                    $ysum3 = $ycount3 * 90;
                    $pyuan3 = $ysum3 / $ycount3;
                }else{
                    if(empty($detail3)){
                        // 计算entry表中的数据
                        foreach($entry3 as $key31 => $value31){
                            $entry31[] = $value31['score'];
                        }
                        $cha3 = array_sum($entry31);
                        $ycount3 = count($score0);
                        $ysum3= $ycount3 * 90 + $cha3;
                        $pyuan3 = round($ysum3 / $ycount3,2);
                    }elseif(empty($entry3)){
                        // 计算detail表中的数据
                        foreach($detail3 as $key32 => $value32){
                            $detail31[] = $value32['score'];
                        }
                        $cha3 = array_sum($detail31);
                        $ycount3 = count($score0);
                        $ysum3 = $ycount3 * 90 + $cha3;
                        $pyuan3 = round($ysum3 / $ycount3,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail3 as $key33 => $value33){
                            $detail31[] = $value33['score'];
                        }
                        foreach($entry3 as $key33 => $value33){
                            $entry31[] = $value33['score'];
                        }
                        $chaz311 = array_sum($detail31);
                        $chaz312 = array_sum($entry31);
                        $cha3 = $chaz311 + $chaz312;
                        $ycount3 = count($score0);
                        $ysum3 = $ycount3 * 90 + $cha3;
                        $pyuan3 = round($ysum3 / $ycount3,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where32['ktime'] = $ktime;
                $where32['mtime'] = array('in',$ktime7);
                $where32['score_id'] = array('in',$xinz_id);
                $where33['ktime'] = $ktime;
                $where33['mtime'] = array('in',$ktime6);
                $where33['score_id'] = array('in',$xinz_id);
                $detail31 = M('detail')->where($where32)->select();
                $entry31 = M('entry')->where($where33)->select();
                if(empty($detail31) && empty($entry31)){
                    // 默认值
                    $xcount3 = count($score1);
                    $xsum3 = $xcount3 * 90;
                    $pxinz3 = $xsum3 / $xcount3;
                }else{
                    if(empty($detail31)){
                        // 计算entry表中的数据
                        foreach($entry31 as $key41 => $value41){
                            $entry32[] = $value41['score'];
                        }
                        $cha3 = array_sum($entry32);
                        $xcount3 = count($score1);
                        $xsum3 = $xcount3 * 90 + $cha3;
                        $pxinz3 = round($xsum3 / $xcount3,2);
                    }elseif(empty($entry31)){
                        // 计算detail表中的数据
                        foreach($detail31 as $key42 => $value42){
                            $detail32[] = $value42['score'];
                        }
                        $cha3 = array_sum($detail32);
                        $xcount3 = count($score1);
                        $xsum3 = $xcount3 * 90 + $cha3;
                        $pxinz3 = round($xsum3 / $xcount3,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail31 as $key43 => $value43){
                            $detail32[] = $value43['score'];
                        }
                        foreach($entry31 as $key43 => $value43){
                            $entry32[] = $value43['score'];
                        }
                        $chaz311 = array_sum($detail32);
                        $chaz312 = array_sum($entry32);
                        $cha3 = $chaz311 + $chaz312;
                        $xcount3 = count($score1);
                        $xsum3 = $xcount3 * 90 + $cha3;
                        $pxinz3 = round($xsum3 / $xcount3,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where34['ktime'] = $ktime;
                $where34['mtime'] = array('in',$ktime7);
                $where34['score_id'] = array('in',$fuz_id);
                $where35['ktime'] = $ktime;
                $where35['mtime'] = array('in',$ktime6);
                $where35['score_id'] = array('in',$fuz_id);
                $detail32 = M('detail')->where($where34)->select();
                $entry32 = M('entry')->where($where35)->select();
                if(empty($detail32) && empty($entry32)){
                    // 默认值
                    $fcount3 = count($score2);
                    $fsum3 = $fcount3 * 90;
                    $pfuz3 = $fsum3 / $fcount3;
                }else{
                    if(empty($detail32)){
                        // 计算entry表中的数据
                        foreach($entry32 as $key51 => $value51){
                            $entry33[] = $value51['score'];
                        }
                        $cha3 = array_sum($entry33);
                        $fcount3 = count($score2);
                        $fsum3 = $fcount3 * 90 + $cha3;
                        $pfuz3 = round($fsum3 / $fcount3,2);
                    }elseif(empty($entry32)){
                        // 计算detail表中的数据
                        foreach($detail32 as $key52 => $value52){
                            $detail33[] = $value52['score'];
                        }
                        $cha3 = array_sum($detail33);
                        $fcount3 = count($score2);
                        $fsum3 = $fcount3 * 90 + $cha3;
                        $pfuz3 = round($fsum3 / $fcount3,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail32 as $key53 => $value53){
                            $detail33[] = $value53['score'];
                        }
                        foreach($entry32 as $key53 => $value53){
                            $entry33[] = $value53['score'];
                        }
                        $chaz321 = array_sum($detail33);
                        $chaz322 = array_sum($entry33);
                        $cha3 = $chaz321 + $chaz322;
                        $fcount3 = count($score2);
                        $fsum3 = $fcount3 * 90 + $cha3;
                        $pfuz3 = round($fsum3 / $fcount3,2);
                    }
                }
                // 三月 结束
                $yuan['2'] = $pyuan3;
                $xinz['2'] = $pxinz3;
                $fuz['2'] = $pfuz3;
                
                // 四月 开始
                for($i = 1;$i <= 4;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime8[] = $ktime1 . '-0' . $v;
                    $ktime9[] = strtotime($ktime1 . '-' . $v);
                }
                // var_dump($ktime6);
                // var_dump($ktime7);die;
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where40['ktime'] = $ktime;
                $where40['mtime'] = array('in',$ktime9);
                $where40['score_id'] = array('in',$yuan_id);
                $where41['ktime'] = $ktime;
                $where41['mtime'] = array('in',$ktime8);
                $where41['score_id'] = array('in',$yuan_id);
                $detail4 = M('detail')->where($where40)->select();
                $entry4 = M('entry')->where($where41)->select();
                if(empty($detail4) && empty($entry4)){
                    // 默认值
                    $ycount4 = count($score0);
                    $ysum4 = $ycount4 * 90;
                    $pyuan4 = $ysum4 / $ycount4;
                }else{
                    if(empty($detail4)){
                        // 计算entry表中的数据
                        foreach($entry4 as $key31 => $value31){
                            $entry41[] = $value31['score'];
                        }
                        $cha4 = array_sum($entry41);
                        $ycount4 = count($score0);
                        $ysum4 = $ycount4 * 90 + $cha4;
                        $pyuan4 = round($ysum4 / $ycount4,2);
                    }elseif(empty($entry4)){
                        // 计算detail表中的数据
                        foreach($detail4 as $key32 => $value32){
                            $detail41[] = $value32['score'];
                        }
                        $cha4 = array_sum($detail31);
                        $ycount4 = count($score0);
                        $ysum4 = $ycount4 * 90 + $cha4;
                        $pyuan4 = round($ysum4 / $ycount4,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail4 as $key33 => $value33){
                            $detail41[] = $value33['score'];
                        }
                        foreach($entry4 as $key33 => $value33){
                            $entry41[] = $value33['score'];
                        }
                        $chaz411 = array_sum($detail41);
                        $chaz412 = array_sum($entry41);
                        $cha4 = $chaz411 + $chaz412;
                        $ycount4 = count($score0);
                        $ysum4 = $ycount4 * 90 + $cha4;
                        $pyuan4 = round($ysum4 / $ycount4,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where42['ktime'] = $ktime;
                $where42['mtime'] = array('in',$ktime9);
                $where42['score_id'] = array('in',$xinz_id);
                $where43['ktime'] = $ktime;
                $where43['mtime'] = array('in',$ktime8);
                $where43['score_id'] = array('in',$xinz_id);
                $detail41 = M('detail')->where($where42)->select();
                $entry41 = M('entry')->where($where43)->select();
                if(empty($detail41) && empty($entry41)){
                    // 默认值
                    $xcount4 = count($score1);
                    $xsum4 = $xcount4 * 90;
                    $pxinz4 = $xsum4 / $xcount4;
                }else{
                    if(empty($detail41)){
                        // 计算entry表中的数据
                        foreach($entry41 as $key41 => $value41){
                            $entry42[] = $value41['score'];
                        }
                        $cha4 = array_sum($entry42);
                        $xcount4 = count($score1);
                        $xsum4 = $xcount4 * 90 + $cha4;
                        $pxinz4 = round($xsum4 / $xcount4,2);
                    }elseif(empty($entry41)){
                        // 计算detail表中的数据
                        foreach($detail41 as $key42 => $value42){
                            $detail42[] = $value42['score'];
                        }
                        $cha4 = array_sum($detail42);
                        $xcount4 = count($score1);
                        $xsum4 = $xcount4 * 90 + $cha4;
                        $pxinz4 = round($xsum4 / $xcount4,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail41 as $key43 => $value43){
                            $detail42[] = $value43['score'];
                        }
                        foreach($entry41 as $key43 => $value43){
                            $entry42[] = $value43['score'];
                        }
                        $chaz411 = array_sum($detail42);
                        $chaz412 = array_sum($entry42);
                        $cha4 = $chaz411 + $chaz412;
                        $xcount4 = count($score1);
                        $xsum4 = $xcount3 * 90 + $cha3;
                        $pxinz4 = round($xsum4 / $xcount4,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where44['ktime'] = $ktime;
                $where44['mtime'] = array('in',$ktime9);
                $where44['score_id'] = array('in',$fuz_id);
                $where45['ktime'] = $ktime;
                $where45['mtime'] = array('in',$ktime8);
                $where45['score_id'] = array('in',$fuz_id);
                $detail42 = M('detail')->where($where44)->select();
                $entry42 = M('entry')->where($where45)->select();
                if(empty($detail42) && empty($entry42)){
                    // 默认值
                    $fcount4 = count($score2);
                    $fsum4 = $fcount4 * 90;
                    $pfuz4 = $fsum4 / $fcount4;
                }else{
                    if(empty($detail42)){
                        // 计算entry表中的数据
                        foreach($entry42 as $key51 => $value51){
                            $entry43[] = $value51['score'];
                        }
                        $cha4 = array_sum($entry43);
                        $fcount4 = count($score2);
                        $fsum4 = $fcount4 * 90 + $cha4;
                        $pfuz4 = round($fsum4 / $fcount4,2);
                    }elseif(empty($entry42)){
                        // 计算detail表中的数据
                        foreach($detail42 as $key52 => $value52){
                            $detail43[] = $value52['score'];
                        }
                        $cha4 = array_sum($detail43);
                        $fcount4 = count($score2);
                        $fsum4 = $fcount4 * 90 + $cha4;
                        $pfuz4 = round($fsum4 / $fcount4,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail42 as $key53 => $value53){
                            $detail43[] = $value53['score'];
                        }
                        foreach($entry42 as $key53 => $value53){
                            $entry43[] = $value53['score'];
                        }
                        $chaz421 = array_sum($detail43);
                        $chaz422 = array_sum($entry43);
                        $cha4 = $chaz421 + $chaz422;
                        $fcount4 = count($score2);
                        $fsum4 = $fcount4 * 90 + $cha4;
                        $pfuz4 = round($fsum4 / $fcount4,2);
                    }
                }
                // 四月 结束
                $yuan['3'] = $pyuan4;
                $xinz['3'] = $pxinz4;
                $fuz['3'] = $pfuz4;

                // 五月 开始
                for($i = 1;$i <= 5;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime10[] = $ktime1 . '-0' . $v;
                    $ktime11[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where50['ktime'] = $ktime;
                $where50['mtime'] = array('in',$ktime11);
                $where50['score_id'] = array('in',$yuan_id);
                $where51['ktime'] = $ktime;
                $where51['mtime'] = array('in',$ktime10);
                $where51['score_id'] = array('in',$yuan_id);
                $detail5 = M('detail')->where($where50)->select();
                $entry5 = M('entry')->where($where51)->select();
                if(empty($detail5) && empty($entry5)){
                    // 默认值
                    $ycount5 = count($score0);
                    $ysum5 = $ycount5 * 90;
                    $pyuan5 = $ysum5 / $ycount5;
                }else{
                    if(empty($detail5)){
                        // 计算entry表中的数据
                        foreach($entry5 as $key31 => $value31){
                            $entry51[] = $value31['score'];
                        }
                        $cha5 = array_sum($entry51);
                        $ycount5 = count($score0);
                        $ysum5 = $ycount5 * 90 + $cha5;
                        $pyuan5 = round($ysum5 / $ycount5,2);
                    }elseif(empty($entry5)){
                        // 计算detail表中的数据
                        foreach($detail5 as $key32 => $value32){
                            $detail51[] = $value32['score'];
                        }
                        $cha5 = array_sum($detail51);
                        $ycount5 = count($score0);
                        $ysum5 = $ycount5 * 90 + $cha5;
                        $pyuan5 = round($ysum5 / $ycount5,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail5 as $key33 => $value33){
                            $detail51[] = $value33['score'];
                        }
                        foreach($entry5 as $key33 => $value33){
                            $entry51[] = $value33['score'];
                        }
                        $chaz511 = array_sum($detail51);
                        $chaz512 = array_sum($entry51);
                        $cha5 = $chaz511 + $chaz512;
                        $ycount5 = count($score0);
                        $ysum5 = $ycount5 * 90 + $cha5;
                        $pyuan5 = round($ysum5 / $ycount5,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where52['ktime'] = $ktime;
                $where52['mtime'] = array('in',$ktime11);
                $where52['score_id'] = array('in',$xinz_id);
                $where53['ktime'] = $ktime;
                $where53['mtime'] = array('in',$ktime10);
                $where53['score_id'] = array('in',$xinz_id);
                $detail51 = M('detail')->where($where52)->select();
                $entry51 = M('entry')->where($where53)->select();
                if(empty($detail51) && empty($entry51)){
                    // 默认值
                    $xcount5 = count($score1);
                    $xsum5 = $xcount5 * 90;
                    $pxinz5 = $xsum5 / $xcount5;
                }else{
                    if(empty($detail51)){
                        // 计算entry表中的数据
                        foreach($entry51 as $key41 => $value41){
                            $entry52[] = $value41['score'];
                        }
                        $cha5 = array_sum($entry52);
                        $xcount5 = count($score1);
                        $xsum5 = $xcount5 * 90 + $cha5;
                        $pxinz5 = round($xsum5 / $xcount5,2);
                    }elseif(empty($entry51)){
                        // 计算detail表中的数据
                        foreach($detail51 as $key42 => $value42){
                            $detail52[] = $value42['score'];
                        }
                        $cha5 = array_sum($detail52);
                        $xcount5 = count($score1);
                        $xsum5 = $xcount5 * 90 + $cha5;
                        $pxinz5 = round($xsum5 / $xcount5,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail51 as $key43 => $value43){
                            $detail52[] = $value43['score'];
                        }
                        foreach($entry51 as $key43 => $value43){
                            $entry52[] = $value43['score'];
                        }
                        $chaz511 = array_sum($detail52);
                        $chaz512 = array_sum($entry52);
                        $cha5 = $chaz511 + $chaz512;
                        $xcount5 = count($score1);
                        $xsum5 = $xcount5 * 90 + $cha5;
                        $pxinz5 = round($xsum5 / $xcount5,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where54['ktime'] = $ktime;
                $where54['mtime'] = array('in',$ktime11);
                $where54['score_id'] = array('in',$fuz_id);
                $where55['ktime'] = $ktime;
                $where55['mtime'] = array('in',$ktime10);
                $where55['score_id'] = array('in',$fuz_id);
                $detail52 = M('detail')->where($where54)->select();
                $entry52 = M('entry')->where($where55)->select();
                if(empty($detail52) && empty($entry52)){
                    // 默认值
                    $fcount5 = count($score2);
                    $fsum5 = $fcount5 * 90;
                    $pfuz5 = $fsum5 / $fcount5;
                }else{
                    if(empty($detail52)){
                        // 计算entry表中的数据
                        foreach($entry52 as $key51 => $value51){
                            $entry53[] = $value51['score'];
                        }
                        $cha5 = array_sum($entry53);
                        $fcount5 = count($score2);
                        $fsum5 = $fcount5 * 90 + $cha5;
                        $pfuz5 = round($fsum5 / $fcount5,2);
                    }elseif(empty($entry52)){
                        // 计算detail表中的数据
                        foreach($detail52 as $key52 => $value52){
                            $detail53[] = $value52['score'];
                        }
                        $cha5 = array_sum($detail53);
                        $fcount5 = count($score2);
                        $fsum5 = $fcount5 * 90 + $cha5;
                        $pfuz5 = round($fsum5 / $fcount5,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail52 as $key53 => $value53){
                            $detail53[] = $value53['score'];
                        }
                        foreach($entry52 as $key53 => $value53){
                            $entry53[] = $value53['score'];
                        }
                        $chaz521 = array_sum($detail53);
                        $chaz522 = array_sum($entry53);
                        $cha5 = $chaz521 + $chaz522;
                        $fcount5 = count($score2);
                        $fsum5 = $fcount5 * 90 + $cha5;
                        $pfuz5 = round($fsum5 / $fcount5,2);
                    }
                }
                // 五月 结束
                $yuan['4'] = $pyuan5;
                $xinz['4'] = $pxinz5;
                $fuz['4'] = $pfuz5;

                // 六月 开始
                for($i = 1;$i <= 6;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime12[] = $ktime1 . '-0' . $v;
                    $ktime13[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where60['ktime'] = $ktime;
                $where60['mtime'] = array('in',$ktime13);
                $where60['score_id'] = array('in',$yuan_id);
                $where61['ktime'] = $ktime;
                $where61['mtime'] = array('in',$ktime12);
                $where61['score_id'] = array('in',$yuan_id);
                $detail6 = M('detail')->where($where60)->select();
                $entry6 = M('entry')->where($where61)->select();
                if(empty($detail6) && empty($entry6)){
                    // 默认值
                    $ycount6 = count($score0);
                    $ysum6 = $ycount6 * 90;
                    $pyuan6 = $ysum6 / $ycount6;
                }else{
                    if(empty($detail6)){
                        // 计算entry表中的数据
                        foreach($entry6 as $key31 => $value31){
                            $entry61[] = $value31['score'];
                        }
                        $cha6 = array_sum($entry61);
                        $ycount6 = count($score0);
                        $ysum6 = $ycount6 * 90 + $cha6;
                        $pyuan6 = round($ysum6 / $ycount6,2);
                    }elseif(empty($entry6)){
                        // 计算detail表中的数据
                        foreach($detail6 as $key32 => $value32){
                            $detail61[] = $value32['score'];
                        }
                        $cha6 = array_sum($detail61);
                        $ycount6 = count($score0);
                        $ysum6 = $ycount6 * 90 + $cha6;
                        $pyuan6 = round($ysum6 / $ycount6,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail6 as $key33 => $value33){
                            $detail61[] = $value33['score'];
                        }
                        foreach($entry6 as $key33 => $value33){
                            $entry61[] = $value33['score'];
                        }
                        $chaz611 = array_sum($detail61);
                        $chaz612 = array_sum($entry61);
                        $cha6 = $chaz611 + $chaz612;
                        $ycount6 = count($score0);
                        $ysum6 = $ycount6 * 90 + $cha6;
                        $pyuan6 = round($ysum6 / $ycount6,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where62['ktime'] = $ktime;
                $where62['mtime'] = array('in',$ktime13);
                $where62['score_id'] = array('in',$xinz_id);
                $where63['ktime'] = $ktime;
                $where63['mtime'] = array('in',$ktime12);
                $where63['score_id'] = array('in',$xinz_id);
                $detail61 = M('detail')->where($where62)->select();
                $entry61 = M('entry')->where($where63)->select();
                if(empty($detail61) && empty($entry61)){
                    // 默认值
                    $xcount6 = count($score1);
                    $xsum6 = $xcount6 * 90;
                    $pxinz6 = $xsum6 / $xcount6;
                }else{
                    if(empty($detail61)){
                        // 计算entry表中的数据
                        foreach($entry61 as $key41 => $value41){
                            $entry62[] = $value41['score'];
                        }
                        $cha6 = array_sum($entry62);
                        $xcount6 = count($score1);
                        $xsum6 = $xcount6 * 90 + $cha6;
                        $pxinz6 = round($xsum6 / $xcount6,2);
                    }elseif(empty($entry61)){
                        // 计算detail表中的数据
                        foreach($detail61 as $key42 => $value42){
                            $detail62[] = $value42['score'];
                        }
                        $cha6 = array_sum($detail62);
                        $xcount6 = count($score1);
                        $xsum6 = $xcount6 * 90 + $cha6;
                        $pxinz6 = round($xsum6 / $xcount6,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail61 as $key43 => $value43){
                            $detail62[] = $value43['score'];
                        }
                        foreach($entry61 as $key43 => $value43){
                            $entry62[] = $value43['score'];
                        }
                        $chaz611 = array_sum($detail62);
                        $chaz612 = array_sum($entry62);
                        $cha6 = $chaz611 + $chaz612;
                        $xcount6 = count($score1);
                        $xsum6 = $xcount6 * 90 + $cha6;
                        $pxinz6 = round($xsum6 / $xcount6,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where64['ktime'] = $ktime;
                $where64['mtime'] = array('in',$ktime13);
                $where64['score_id'] = array('in',$fuz_id);
                $where65['ktime'] = $ktime;
                $where65['mtime'] = array('in',$ktime12);
                $where65['score_id'] = array('in',$fuz_id);
                $detail62 = M('detail')->where($where64)->select();
                $entry62 = M('entry')->where($where65)->select();
                if(empty($detail62) && empty($entry62)){
                    // 默认值
                    $fcount6 = count($score2);
                    $fsum6 = $fcount6 * 90;
                    $pfuz6 = $fsum6 / $fcount6;
                }else{
                    if(empty($detail62)){
                        // 计算entry表中的数据
                        foreach($entry62 as $key51 => $value51){
                            $entry63[] = $value51['score'];
                        }
                        $cha6 = array_sum($entry63);
                        $fcount6 = count($score2);
                        $fsum6 = $fcount6 * 90 + $cha6;
                        $pfuz6 = round($fsum6 / $fcount6,2);
                    }elseif(empty($entry62)){
                        // 计算detail表中的数据
                        foreach($detail62 as $key52 => $value52){
                            $detail63[] = $value52['score'];
                        }
                        $cha6 = array_sum($detail63);
                        $fcount6 = count($score2);
                        $fsum6 = $fcount6 * 90 + $cha6;
                        $pfuz6 = round($fsum6 / $fcount6,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail62 as $key53 => $value53){
                            $detail63[] = $value53['score'];
                        }
                        foreach($entry62 as $key53 => $value53){
                            $entry63[] = $value53['score'];
                        }
                        $chaz621 = array_sum($detail63);
                        $chaz622 = array_sum($entry63);
                        $cha6 = $chaz621 + $chaz622;
                        $fcount6 = count($score2);
                        $fsum6 = $fcount6 * 90 + $cha6;
                        $pfuz6 = round($fsum6 / $fcount6,2);
                    }
                }
                // 六月 结束
                $yuan['5'] = $pyuan6;
                $xinz['5'] = $pxinz6;
                $fuz['5'] = $pfuz6;

                // 七月 开始
                for($i = 1;$i <= 7;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime14[] = $ktime1 . '-0' . $v;
                    $ktime15[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where70['ktime'] = $ktime;
                $where70['mtime'] = array('in',$ktime15);
                $where70['score_id'] = array('in',$yuan_id);
                $where71['ktime'] = $ktime;
                $where71['mtime'] = array('in',$ktime14);
                $where71['score_id'] = array('in',$yuan_id);
                $detail7 = M('detail')->where($where70)->select();
                $entry7 = M('entry')->where($where71)->select();
                if(empty($detail7) && empty($entry7)){
                    // 默认值
                    $ycount7 = count($score0);
                    $ysum7 = $ycount7 * 90;
                    $pyuan7 = $ysum7 / $ycount7;
                }else{
                    if(empty($detail7)){
                        // 计算entry表中的数据
                        foreach($entry7 as $key31 => $value31){
                            $entry71[] = $value31['score'];
                        }
                        $cha7 = array_sum($entry71);
                        $ycount7 = count($score0);
                        $ysum7 = $ycount7 * 90 + $cha7;
                        $pyuan7 = round($ysum7 / $ycount7,2);
                    }elseif(empty($entry7)){
                        // 计算detail表中的数据
                        foreach($detail7 as $key32 => $value32){
                            $detail71[] = $value32['score'];
                        }
                        $cha7 = array_sum($detail71);
                        $ycount7 = count($score0);
                        $ysum7 = $ycount7 * 90 + $cha7;
                        $pyuan7 = round($ysum7 / $ycount7,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail7 as $key33 => $value33){
                            $detail71[] = $value33['score'];
                        }
                        foreach($entry7 as $key33 => $value33){
                            $entry71[] = $value33['score'];
                        }
                        $chaz711 = array_sum($detail71);
                        $chaz712 = array_sum($entry71);
                        $cha7 = $chaz711 + $chaz712;
                        $ycount7 = count($score0);
                        $ysum7 = $ycount7 * 90 + $cha7;
                        $pyuan7 = round($ysum7 / $ycount7,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where72['ktime'] = $ktime;
                $where72['mtime'] = array('in',$ktime15);
                $where72['score_id'] = array('in',$xinz_id);
                $where73['ktime'] = $ktime;
                $where73['mtime'] = array('in',$ktime14);
                $where73['score_id'] = array('in',$xinz_id);
                $detail71 = M('detail')->where($where72)->select();
                $entry71 = M('entry')->where($where73)->select();
                if(empty($detail71) && empty($entry71)){
                    // 默认值
                    $xcount7 = count($score1);
                    $xsum7 = $xcount7 * 90;
                    $pxinz7 = $xsum7 / $xcount7;
                }else{
                    if(empty($detail71)){
                        // 计算entry表中的数据
                        foreach($entry71 as $key41 => $value41){
                            $entry72[] = $value41['score'];
                        }
                        $cha7 = array_sum($entry72);
                        $xcount7 = count($score1);
                        $xsum7 = $xcount7 * 90 + $cha7;
                        $pxinz7 = round($xsum7 / $xcount7,2);
                    }elseif(empty($entry71)){
                        // 计算detail表中的数据
                        foreach($detail71 as $key42 => $value42){
                            $detail72[] = $value42['score'];
                        }
                        $cha7 = array_sum($detail72);
                        $xcount7 = count($score1);
                        $xsum7 = $xcount7 * 90 + $cha7;
                        $pxinz7 = round($xsum7 / $xcount7,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail71 as $key43 => $value43){
                            $detail72[] = $value43['score'];
                        }
                        foreach($entry71 as $key43 => $value43){
                            $entry72[] = $value43['score'];
                        }
                        $chaz711 = array_sum($detail72);
                        $chaz712 = array_sum($entry72);
                        $cha7 = $chaz711 + $chaz712;
                        $xcount7 = count($score1);
                        $xsum7 = $xcount7 * 90 + $cha7;
                        $pxinz7 = round($xsum7 / $xcount7,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where74['ktime'] = $ktime;
                $where74['mtime'] = array('in',$ktime15);
                $where74['score_id'] = array('in',$fuz_id);
                $where75['ktime'] = $ktime;
                $where75['mtime'] = array('in',$ktime14);
                $where75['score_id'] = array('in',$fuz_id);
                $detail72 = M('detail')->where($where74)->select();
                $entry72 = M('entry')->where($where75)->select();
                if(empty($detail72) && empty($entry72)){
                    // 默认值
                    $fcount7 = count($score2);
                    $fsum7 = $fcount7 * 90;
                    $pfuz7 = $fsum7 / $fcount7;
                }else{
                    if(empty($detail72)){
                        // 计算entry表中的数据
                        foreach($entry72 as $key51 => $value51){
                            $entry73[] = $value51['score'];
                        }
                        $cha7 = array_sum($entry73);
                        $fcount7 = count($score2);
                        $fsum7 = $fcount7 * 90 + $cha7;
                        $pfuz7 = round($fsum7 / $fcount7,2);
                    }elseif(empty($entry72)){
                        // 计算detail表中的数据
                        foreach($detail72 as $key52 => $value52){
                            $detail73[] = $value52['score'];
                        }
                        $cha7 = array_sum($detail73);
                        $fcount7 = count($score2);
                        $fsum7 = $fcount7 * 90 + $cha7;
                        $pfuz7 = round($fsum7 / $fcount7,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail72 as $key53 => $value53){
                            $detail73[] = $value53['score'];
                        }
                        foreach($entry72 as $key53 => $value53){
                            $entry73[] = $value53['score'];
                        }
                        $chaz721 = array_sum($detail73);
                        $chaz722 = array_sum($entry73);
                        $cha7 = $chaz721 + $chaz722;
                        $fcount7 = count($score2);
                        $fsum7 = $fcount7 * 90 + $cha7;
                        $pfuz7 = round($fsum7 / $fcount7,2);
                    }
                }
                // 七月 结束
                $yuan['6'] = $pyuan7;
                $xinz['6'] = $pxinz7;
                $fuz['6'] = $pfuz7;

                // 八月 开始
                for($i = 1;$i <= 8;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime16[] = $ktime1 . '-0' . $v;
                    $ktime17[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where80['ktime'] = $ktime;
                $where80['mtime'] = array('in',$ktime17);
                $where80['score_id'] = array('in',$yuan_id);
                $where81['ktime'] = $ktime;
                $where81['mtime'] = array('in',$ktime16);
                $where81['score_id'] = array('in',$yuan_id);
                $detail8 = M('detail')->where($where80)->select();
                $entry8 = M('entry')->where($where81)->select();
                if(empty($detail8) && empty($entry8)){
                    // 默认值
                    $ycount8 = count($score0);
                    $ysum8 = $ycount8 * 90;
                    $pyuan8 = $ysum8 / $ycount8;
                }else{
                    if(empty($detail8)){
                        // 计算entry表中的数据
                        foreach($entry8 as $key31 => $value31){
                            $entry81[] = $value31['score'];
                        }
                        $cha8 = array_sum($entry81);
                        $ycount8 = count($score0);
                        $ysum8 = $ycount8 * 90 + $cha8;
                        $pyuan8 = round($ysum8 / $ycount8,2);
                    }elseif(empty($entry8)){
                        // 计算detail表中的数据
                        foreach($detail8 as $key32 => $value32){
                            $detail81[] = $value32['score'];
                        }
                        $cha8 = array_sum($detail81);
                        $ycount8 = count($score0);
                        $ysum8 = $ycount8 * 90 + $cha8;
                        $pyuan8 = round($ysum8 / $ycount8,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail8 as $key33 => $value33){
                            $detail81[] = $value33['score'];
                        }
                        foreach($entry8 as $key33 => $value33){
                            $entry81[] = $value33['score'];
                        }
                        $chaz811 = array_sum($detail81);
                        $chaz812 = array_sum($entry81);
                        $cha8 = $chaz811 + $chaz812;
                        $ycount8 = count($score0);
                        $ysum8 = $ycount8 * 90 + $cha8;
                        $pyuan8 = round($ysum8 / $ycount8,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where82['ktime'] = $ktime;
                $where82['mtime'] = array('in',$ktime17);
                $where82['score_id'] = array('in',$xinz_id);
                $where83['ktime'] = $ktime;
                $where83['mtime'] = array('in',$ktime16);
                $where83['score_id'] = array('in',$xinz_id);
                $detail81 = M('detail')->where($where82)->select();
                $entry81 = M('entry')->where($where83)->select();
                if(empty($detail81) && empty($entry81)){
                    // 默认值
                    $xcount8 = count($score1);
                    $xsum8 = $xcount8 * 90;
                    $pxinz8 = $xsum8 / $xcount8;
                }else{
                    if(empty($detail81)){
                        // 计算entry表中的数据
                        foreach($entry81 as $key41 => $value41){
                            $entry82[] = $value41['score'];
                        }
                        $cha8 = array_sum($entry82);
                        $xcount8 = count($score1);
                        $xsum8 = $xcount8 * 90 + $cha8;
                        $pxinz8 = round($xsum8 / $xcount8,2);
                    }elseif(empty($entry81)){
                        // 计算detail表中的数据
                        foreach($detail81 as $key42 => $value42){
                            $detail82[] = $value42['score'];
                        }
                        $cha8 = array_sum($detail82);
                        $xcount8 = count($score1);
                        $xsum8 = $xcount8 * 90 + $cha8;
                        $pxinz8 = round($xsum8 / $xcount8,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail81 as $key43 => $value43){
                            $detail82[] = $value43['score'];
                        }
                        foreach($entry81 as $key43 => $value43){
                            $entry82[] = $value43['score'];
                        }
                        $chaz811 = array_sum($detail82);
                        $chaz812 = array_sum($entry82);
                        $cha8 = $chaz811 + $chaz812;
                        $xcount8 = count($score1);
                        $xsum8 = $xcount8 * 90 + $cha8;
                        $pxinz8 = round($xsum8 / $xcount8,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where84['ktime'] = $ktime;
                $where84['mtime'] = array('in',$ktime17);
                $where84['score_id'] = array('in',$fuz_id);
                $where85['ktime'] = $ktime;
                $where85['mtime'] = array('in',$ktime16);
                $where85['score_id'] = array('in',$fuz_id);
                $detail82 = M('detail')->where($where84)->select();
                $entry82 = M('entry')->where($where85)->select();
                if(empty($detail82) && empty($entry82)){
                    // 默认值
                    $fcount8 = count($score2);
                    $fsum8 = $fcount8 * 90;
                    $pfuz8 = $fsum8 / $fcount8;
                }else{
                    if(empty($detail82)){
                        // 计算entry表中的数据
                        foreach($entry82 as $key51 => $value51){
                            $entry83[] = $value51['score'];
                        }
                        $cha8 = array_sum($entry83);
                        $fcount8 = count($score2);
                        $fsum8 = $fcount8 * 90 + $cha8;
                        $pfuz8 = round($fsum8 / $fcount8,2);
                    }elseif(empty($entry82)){
                        // 计算detail表中的数据
                        foreach($detail82 as $key52 => $value52){
                            $detail83[] = $value52['score'];
                        }
                        $cha8 = array_sum($detail83);
                        $fcount8 = count($score2);
                        $fsum8 = $fcount8 * 90 + $cha8;
                        $pfuz8 = round($fsum8 / $fcount8,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail82 as $key53 => $value53){
                            $detail83[] = $value53['score'];
                        }
                        foreach($entry82 as $key53 => $value53){
                            $entry83[] = $value53['score'];
                        }
                        $chaz821 = array_sum($detail83);
                        $chaz822 = array_sum($entry83);
                        $cha8 = $chaz821 + $chaz822;
                        $fcount8 = count($score2);
                        $fsum8 = $fcount8 * 90 + $cha8;
                        $pfuz8 = round($fsum8 / $fcount8,2);
                    }
                }
                // 八月 结束
                $yuan['7'] = $pyuan8;
                $xinz['7'] = $pxinz8;
                $fuz['7'] = $pfuz8;

                // 九月 开始
                for($i = 1;$i <= 9;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime18[] = $ktime1 . '-0' . $v;
                    $ktime19[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where90['ktime'] = $ktime;
                $where90['mtime'] = array('in',$ktime19);
                $where90['score_id'] = array('in',$yuan_id);
                $where91['ktime'] = $ktime;
                $where91['mtime'] = array('in',$ktime18);
                $where91['score_id'] = array('in',$yuan_id);
                $detail9 = M('detail')->where($where90)->select();
                $entry9 = M('entry')->where($where91)->select();
                if(empty($detail9) && empty($entry9)){
                    // 默认值
                    $ycount9 = count($score0);
                    $ysum9 = $ycount9 * 90;
                    $pyuan9 = $ysum9 / $ycount9;
                }else{
                    if(empty($detail9)){
                        // 计算entry表中的数据
                        foreach($entry9 as $key31 => $value31){
                            $entry91[] = $value31['score'];
                        }
                        $cha9 = array_sum($entry91);
                        $ycount9 = count($score0);
                        $ysum9 = $ycount9 * 90 + $cha9;
                        $pyuan9 = round($ysum9 / $ycount9,2);
                    }elseif(empty($entry9)){
                        // 计算detail表中的数据
                        foreach($detail9 as $key32 => $value32){
                            $detail91[] = $value32['score'];
                        }
                        $cha9 = array_sum($detail91);
                        $ycount9 = count($score0);
                        $ysum9 = $ycount9 * 90 + $cha9;
                        $pyuan9 = round($ysum9 / $ycount9,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail9 as $key33 => $value33){
                            $detail91[] = $value33['score'];
                        }
                        foreach($entry9 as $key33 => $value33){
                            $entry91[] = $value33['score'];
                        }
                        $chaz911 = array_sum($detail91);
                        $chaz912 = array_sum($entry91);
                        $cha9 = $chaz911 + $chaz912;
                        $ycount9 = count($score0);
                        $ysum9 = $ycount9 * 90 + $cha9;
                        $pyuan9 = round($ysum9 / $ycount9,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where92['ktime'] = $ktime;
                $where92['mtime'] = array('in',$ktime19);
                $where92['score_id'] = array('in',$xinz_id);
                $where93['ktime'] = $ktime;
                $where93['mtime'] = array('in',$ktime18);
                $where93['score_id'] = array('in',$xinz_id);
                $detail91 = M('detail')->where($where92)->select();
                $entry91 = M('entry')->where($where93)->select();
                if(empty($detail91) && empty($entry91)){
                    // 默认值
                    $xcount9 = count($score1);
                    $xsum9 = $xcount9 * 90;
                    $pxinz9 = $xsum9 / $xcount9;
                }else{
                    if(empty($detail91)){
                        // 计算entry表中的数据
                        foreach($entry91 as $key41 => $value41){
                            $entry92[] = $value41['score'];
                        }
                        $cha9 = array_sum($entry92);
                        $xcount9 = count($score1);
                        $xsum9 = $xcount9 * 90 + $cha9;
                        $pxinz9 = round($xsum9 / $xcount9,2);
                    }elseif(empty($entry91)){
                        // 计算detail表中的数据
                        foreach($detail91 as $key42 => $value42){
                            $detail92[] = $value42['score'];
                        }
                        $cha9 = array_sum($detail92);
                        $xcount9 = count($score1);
                        $xsum9 = $xcount9 * 90 + $cha9;
                        $pxinz9 = round($xsum9 / $xcount9,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail91 as $key43 => $value43){
                            $detail92[] = $value43['score'];
                        }
                        foreach($entry91 as $key43 => $value43){
                            $entry92[] = $value43['score'];
                        }
                        $chaz911 = array_sum($detail92);
                        $chaz912 = array_sum($entry92);
                        $cha9 = $chaz911 + $chaz912;
                        $xcount9 = count($score1);
                        $xsum9 = $xcount9 * 90 + $cha9;
                        $pxinz9 = round($xsum9 / $xcount9,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where94['ktime'] = $ktime;
                $where94['mtime'] = array('in',$ktime19);
                $where94['score_id'] = array('in',$fuz_id);
                $where95['ktime'] = $ktime;
                $where95['mtime'] = array('in',$ktime18);
                $where95['score_id'] = array('in',$fuz_id);
                $detail92 = M('detail')->where($where94)->select();
                $entry92 = M('entry')->where($where95)->select();
                if(empty($detail92) && empty($entry92)){
                    // 默认值
                    $fcount9 = count($score2);
                    $fsum9 = $fcount9 * 90;
                    $pfuz9 = $fsum9 / $fcount9;
                }else{
                    if(empty($detail92)){
                        // 计算entry表中的数据
                        foreach($entry92 as $key51 => $value51){
                            $entry93[] = $value51['score'];
                        }
                        $cha9 = array_sum($entry93);
                        $fcount9 = count($score2);
                        $fsum9 = $fcount9 * 90 + $cha9;
                        $pfuz9 = round($fsum9 / $fcount9,2);
                    }elseif(empty($entry92)){
                        // 计算detail表中的数据
                        foreach($detail92 as $key52 => $value52){
                            $detail93[] = $value52['score'];
                        }
                        $cha9 = array_sum($detail93);
                        $fcount9 = count($score2);
                        $fsum9 = $fcount9 * 90 + $cha9;
                        $pfuz9 = round($fsum9 / $fcount9,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail92 as $key53 => $value53){
                            $detail93[] = $value53['score'];
                        }
                        foreach($entry92 as $key53 => $value53){
                            $entry93[] = $value53['score'];
                        }
                        $chaz921 = array_sum($detail93);
                        $chaz922 = array_sum($entry93);
                        $cha9 = $chaz921 + $chaz922;
                        $fcount9 = count($score2);
                        $fsum9 = $fcount9 * 90 + $cha9;
                        $pfuz9 = round($fsum9 / $fcount9,2);
                    }
                }
                // 九月 结束
                $yuan['8'] = $pyuan9;
                $xinz['8'] = $pxinz9;
                $fuz['8'] = $pfuz9;

                // 十月 开始
                for($i = 1;$i <= 10;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime20[] = $ktime1 . '-' . $v;
                    $ktime21[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where100['ktime'] = $ktime;
                $where100['mtime'] = array('in',$ktime21);
                $where100['score_id'] = array('in',$yuan_id);
                $where101['ktime'] = $ktime;
                $where101['mtime'] = array('in',$ktime20);
                $where101['score_id'] = array('in',$yuan_id);
                $detail10 = M('detail')->where($where100)->select();
                $entry10 = M('entry')->where($where101)->select();
                if(empty($detail10) && empty($entry10)){
                    // 默认值
                    $ycount10 = count($score0);
                    $ysum10 = $ycount10 * 90;
                    $pyuan10 = $ysum10 / $ycount10;
                }else{
                    if(empty($detail10)){
                        // 计算entry表中的数据
                        foreach($entry10 as $key31 => $value31){
                            $entry101[] = $value31['score'];
                        }
                        $cha10 = array_sum($entry101);
                        $ycount10 = count($score0);
                        $ysum10 = $ycount10 * 90 + $cha10;
                        $pyuan10 = round($ysum10 / $ycount10,2);
                    }elseif(empty($entry10)){
                        // 计算detail表中的数据
                        foreach($detail10 as $key32 => $value32){
                            $detail101[] = $value32['score'];
                        }
                        $cha10 = array_sum($detail101);
                        $ycount10 = count($score0);
                        $ysum10 = $ycount10 * 90 + $cha10;
                        $pyuan10 = round($ysum10 / $ycount10,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail10 as $key33 => $value33){
                            $detail101[] = $value33['score'];
                        }
                        foreach($entry10 as $key33 => $value33){
                            $entry101[] = $value33['score'];
                        }
                        $chaz1011 = array_sum($detail101);
                        $chaz1012 = array_sum($entry101);
                        $cha10 = $chaz1011 + $chaz1012;
                        $ycount10 = count($score0);
                        $ysum10 = $ycount10 * 90 + $cha10;
                        $pyuan10 = round($ysum10 / $ycount10,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where102['ktime'] = $ktime;
                $where102['mtime'] = array('in',$ktime21);
                $where102['score_id'] = array('in',$xinz_id);
                $where103['ktime'] = $ktime;
                $where103['mtime'] = array('in',$ktime20);
                $where103['score_id'] = array('in',$xinz_id);
                $detail101 = M('detail')->where($where102)->select();
                $entry101 = M('entry')->where($where103)->select();
                if(empty($detail101) && empty($entry101)){
                    // 默认值
                    $xcount10 = count($score1);
                    $xsum10 = $xcount10 * 90;
                    $pxinz10 = $xsum10 / $xcount10;
                }else{
                    if(empty($detail101)){
                        // 计算entry表中的数据
                        foreach($entry101 as $key41 => $value41){
                            $entry102[] = $value41['score'];
                        }
                        $cha10 = array_sum($entry102);
                        $xcount10 = count($score1);
                        $xsum10 = $xcount10 * 90 + $cha10;
                        $pxinz10 = round($xsum10 / $xcount10,2);
                    }elseif(empty($entry101)){
                        // 计算detail表中的数据
                        foreach($detail101 as $key42 => $value42){
                            $detail102[] = $value42['score'];
                        }
                        $cha10 = array_sum($detail102);
                        $xcount10 = count($score1);
                        $xsum10 = $xcount10 * 90 + $cha10;
                        $pxinz10 = round($xsum10 / $xcount10,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail101 as $key43 => $value43){
                            $detail102[] = $value43['score'];
                        }
                        foreach($entry31 as $key43 => $value43){
                            $entry102[] = $value43['score'];
                        }
                        $chaz1011 = array_sum($detail102);
                        $chaz1012 = array_sum($entry102);
                        $cha10 = $chaz1011 + $chaz1012;
                        $xcount10 = count($score1);
                        $xsum10 = $xcount10 * 90 + $cha10;
                        $pxinz10 = round($xsum10 / $xcount10,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where104['ktime'] = $ktime;
                $where104['mtime'] = array('in',$ktime21);
                $where104['score_id'] = array('in',$fuz_id);
                $where105['ktime'] = $ktime;
                $where105['mtime'] = array('in',$ktime20);
                $where105['score_id'] = array('in',$fuz_id);
                $detail102 = M('detail')->where($where104)->select();
                $entry102 = M('entry')->where($where105)->select();
                if(empty($detail102) && empty($entry102)){
                    // 默认值
                    $fcount10 = count($score2);
                    $fsum10 = $fcount10 * 90;
                    $pfuz10 = $fsum10 / $fcount10;
                }else{
                    if(empty($detail102)){
                        // 计算entry表中的数据
                        foreach($entry102 as $key51 => $value51){
                            $entry103[] = $value51['score'];
                        }
                        $cha10 = array_sum($entry103);
                        $fcount10 = count($score2);
                        $fsum10 = $fcount10 * 90 + $cha10;
                        $pfuz10 = round($fsum10 / $fcount10,2);
                    }elseif(empty($entry102)){
                        // 计算detail表中的数据
                        foreach($detail102 as $key52 => $value52){
                            $detail103[] = $value52['score'];
                        }
                        $cha10 = array_sum($detail103);
                        $fcount10 = count($score2);
                        $fsum10 = $fcount10 * 90 + $cha10;
                        $pfuz10 = round($fsum10 / $fcount10,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail102 as $key53 => $value53){
                            $detail103[] = $value53['score'];
                        }
                        foreach($entry102 as $key53 => $value53){
                            $entry103[] = $value53['score'];
                        }
                        $chaz1021 = array_sum($detail103);
                        $chaz1022 = array_sum($entry103);
                        $cha10 = $chaz1021 + $chaz1022;
                        $fcount10 = count($score2);
                        $fsum10 = $fcount10 * 90 + $cha10;
                        $pfuz10 = round($fsum10 / $fcount10,2);
                    }
                }
                // 十月 结束
                $yuan['9'] = $pyuan10;
                $xinz['9'] = $pxinz10;
                $fuz['9'] = $pfuz10;

                // 十一月 开始
                for($i = 1;$i <= 11;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime22[] = $ktime1 . '-0' . $v;
                    $ktime23[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where110['ktime'] = $ktime;
                $where110['mtime'] = array('in',$ktime23);
                $where110['score_id'] = array('in',$yuan_id);
                $where111['ktime'] = $ktime;
                $where111['mtime'] = array('in',$ktime22);
                $where111['score_id'] = array('in',$yuan_id);
                $detail11 = M('detail')->where($where110)->select();
                $entry11 = M('entry')->where($where111)->select();
                if(empty($detail11) && empty($entry11)){
                    // 默认值
                    $ycount11 = count($score0);
                    $ysum11 = $ycount11 * 90;
                    $pyuan11 = $ysum11 / $ycount11;
                }else{
                    if(empty($detail11)){
                        // 计算entry表中的数据
                        foreach($entry11 as $key31 => $value31){
                            $entry111[] = $value31['score'];
                        }
                        $cha11 = array_sum($entry111);
                        $ycount11 = count($score0);
                        $ysum11 = $ycount11 * 90 + $cha11;
                        $pyuan11 = round($ysum11 / $ycount11,2);
                    }elseif(empty($entry11)){
                        // 计算detail表中的数据
                        foreach($detail11 as $key32 => $value32){
                            $detail111[] = $value32['score'];
                        }
                        $cha11 = array_sum($detail111);
                        $ycount11 = count($score0);
                        $ysum11 = $ycount11 * 90 + $cha11;
                        $pyuan11 = round($ysum11 / $ycount11,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail11 as $key33 => $value33){
                            $detail111[] = $value33['score'];
                        }
                        foreach($entry11 as $key33 => $value33){
                            $entry111[] = $value33['score'];
                        }
                        $chaz1111 = array_sum($detail111);
                        $chaz1112 = array_sum($entry111);
                        $cha11 = $chaz1111 + $chaz1112;
                        $ycount11 = count($score0);
                        $ysum11 = $ycount11 * 90 + $cha11;
                        $pyuan11 = round($ysum11 / $ycount11,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where112['ktime'] = $ktime;
                $where112['mtime'] = array('in',$ktime23);
                $where112['score_id'] = array('in',$xinz_id);
                $where113['ktime'] = $ktime;
                $where113['mtime'] = array('in',$ktime22);
                $where113['score_id'] = array('in',$xinz_id);
                $detail111 = M('detail')->where($where112)->select();
                $entry111 = M('entry')->where($where113)->select();
                if(empty($detail111) && empty($entry111)){
                    // 默认值
                    $xcount11 = count($score1);
                    $xsum11 = $xcount11 * 90;
                    $pxinz11 = $xsum11 / $xcount11;
                }else{
                    if(empty($detail111)){
                        // 计算entry表中的数据
                        foreach($entry111 as $key41 => $value41){
                            $entry112[] = $value41['score'];
                        }
                        $cha11 = array_sum($entry112);
                        $xcount11 = count($score1);
                        $xsum11 = $xcount11 * 90 + $cha11;
                        $pxinz11 = round($xsum11 / $xcount11,2);
                    }elseif(empty($entry111)){
                        // 计算detail表中的数据
                        foreach($detail111 as $key42 => $value42){
                            $detail112[] = $value42['score'];
                        }
                        $cha11 = array_sum($detail112);
                        $xcount11 = count($score1);
                        $xsum11 = $xcount11 * 90 + $cha11;
                        $pxinz11 = round($xsum11 / $xcount11,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail111 as $key43 => $value43){
                            $detail112[] = $value43['score'];
                        }
                        foreach($entry111 as $key43 => $value43){
                            $entry112[] = $value43['score'];
                        }
                        $chaz1111 = array_sum($detail112);
                        $chaz1112 = array_sum($entry112);
                        $cha11 = $chaz1111 + $chaz1112;
                        $xcount11 = count($score1);
                        $xsum11 = $xcount11 * 90 + $cha11;
                        $pxinz11 = round($xsum11 / $xcount11,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where114['ktime'] = $ktime;
                $where114['mtime'] = array('in',$ktime23);
                $where114['score_id'] = array('in',$fuz_id);
                $where115['ktime'] = $ktime;
                $where115['mtime'] = array('in',$ktime22);
                $where115['score_id'] = array('in',$fuz_id);
                $detail112 = M('detail')->where($where114)->select();
                $entry112 = M('entry')->where($where115)->select();
                if(empty($detail112) && empty($entry112)){
                    // 默认值
                    $fcount11 = count($score2);
                    $fsum11 = $fcount11 * 90;
                    $pfuz11 = $fsum11 / $fcount11;
                }else{
                    if(empty($detail112)){
                        // 计算entry表中的数据
                        foreach($entry112 as $key51 => $value51){
                            $entry113[] = $value51['score'];
                        }
                        $cha11 = array_sum($entry113);
                        $fcount11 = count($score2);
                        $fsum11 = $fcount11 * 90 + $cha11;
                        $pfuz11 = round($fsum11 / $fcount11,2);
                    }elseif(empty($entry112)){
                        // 计算detail表中的数据
                        foreach($detail112 as $key52 => $value52){
                            $detail113[] = $value52['score'];
                        }
                        $cha11 = array_sum($detail113);
                        $fcount11 = count($score2);
                        $fsum11 = $fcount11 * 90 + $cha11;
                        $pfuz11 = round($fsum11 / $fcount11,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail112 as $key53 => $value53){
                            $detail113[] = $value53['score'];
                        }
                        foreach($entry112 as $key53 => $value53){
                            $entry113[] = $value53['score'];
                        }
                        $chaz1121 = array_sum($detail113);
                        $chaz1122 = array_sum($entry113);
                        $cha11 = $chaz1121 + $chaz1122;
                        $fcount11 = count($score2);
                        $fsum11 = $fcount11 * 90 + $cha11;
                        $pfuz11 = round($fsum11 / $fcount11,2);
                    }
                }
                // 十一月 结束
                $yuan['10'] = $pyuan11;
                $xinz['10'] = $pxinz11;
                $fuz['10'] = $pfuz11;

                // 十二月 开始
                for($i = 1;$i <= 12;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime24[] = $ktime1 . '-0' . $v;
                    $ktime25[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where120['ktime'] = $ktime;
                $where120['mtime'] = array('in',$ktime25);
                $where120['score_id'] = array('in',$yuan_id);
                $where121['ktime'] = $ktime;
                $where121['mtime'] = array('in',$ktime24);
                $where121['score_id'] = array('in',$yuan_id);
                $detail12 = M('detail')->where($where120)->select();
                $entry12 = M('entry')->where($where121)->select();
                if(empty($detail12) && empty($entry12)){
                    // 默认值
                    $ycount12 = count($score0);
                    $ysum12 = $ycount12 * 90;
                    $pyuan12 = $ysum12 / $ycount12;
                }else{
                    if(empty($detail12)){
                        // 计算entry表中的数据
                        foreach($entry12 as $key31 => $value31){
                            $entry121[] = $value31['score'];
                        }
                        $cha12 = array_sum($entry121);
                        $ycount12 = count($score0);
                        $ysum12 = $ycount12 * 90 + $cha12;
                        $pyuan12 = round($ysum12 / $ycount12,2);
                    }elseif(empty($entry12)){
                        // 计算detail表中的数据
                        foreach($detail12 as $key32 => $value32){
                            $detail121[] = $value32['score'];
                        }
                        $cha12 = array_sum($detail121);
                        $ycount12 = count($score0);
                        $ysum12 = $ycount12 * 90 + $cha12;
                        $pyuan12 = round($ysum12 / $ycount12,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail12 as $key33 => $value33){
                            $detail121[] = $value33['score'];
                        }
                        foreach($entry12 as $key33 => $value33){
                            $entry121[] = $value33['score'];
                        }
                        $chaz1211 = array_sum($detail121);
                        $chaz1212 = array_sum($entry121);
                        $cha12 = $chaz1211 + $chaz1212;
                        $ycount12 = count($score0);
                        $ysum12 = $ycount12 * 90 + $cha12;
                        $pyuan12 = round($ysum12 / $ycount12,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where122['ktime'] = $ktime;
                $where122['mtime'] = array('in',$ktime25);
                $where122['score_id'] = array('in',$xinz_id);
                $where123['ktime'] = $ktime;
                $where123['mtime'] = array('in',$ktime24);
                $where123['score_id'] = array('in',$xinz_id);
                $detail121 = M('detail')->where($where122)->select();
                $entry121 = M('entry')->where($where123)->select();
                if(empty($detail121) && empty($entry121)){
                    // 默认值
                    $xcount12 = count($score1);
                    $xsum12 = $xcount12 * 90;
                    $pxinz12 = $xsum12 / $xcount12;
                }else{
                    if(empty($detail121)){
                        // 计算entry表中的数据
                        foreach($entry121 as $key41 => $value41){
                            $entry122[] = $value41['score'];
                        }
                        $cha12 = array_sum($entry122);
                        $xcount12 = count($score1);
                        $xsum12 = $xcount12 * 90 + $cha12;
                        $pxinz12 = round(12 / $xcount12,2);
                    }elseif(empty($entry121)){
                        // 计算detail表中的数据
                        foreach($detail121 as $key42 => $value42){
                            $detail122[] = $value42['score'];
                        }
                        $cha12 = array_sum($detail122);
                        $xcount12 = count($score1);
                        $xsum12 = $xcount12 * 90 + $cha12;
                        $pxinz12 = round($xsum12 / $xcount12,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail121 as $key43 => $value43){
                            $detail122[] = $value43['score'];
                        }
                        foreach($entry121 as $key43 => $value43){
                            $entry122[] = $value43['score'];
                        }
                        $chaz1211 = array_sum($detail122);
                        $chaz1212 = array_sum($entry122);
                        $cha12 = $chaz1211 + $chaz1212;
                        $xcount12 = count($score1);
                        $xsum12 = $xcount12 * 90 + $cha12;
                        $pxinz12 = round($xsum12 / $xcount12,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where124['ktime'] = $ktime;
                $where124['mtime'] = array('in',$ktime25);
                $where124['score_id'] = array('in',$fuz_id);
                $where125['ktime'] = $ktime;
                $where125['mtime'] = array('in',$ktime24);
                $where125['score_id'] = array('in',$fuz_id);
                $detail122 = M('detail')->where($where124)->select();
                $entry122 = M('entry')->where($where125)->select();
                if(empty($detail122) && empty($entry122)){
                    // 默认值
                    $fcount12 = count($score2);
                    $fsum12 = $fcount12 * 90;
                    $pfuz12 = $fsum12 / $fcount12;
                }else{
                    if(empty($detail122)){
                        // 计算entry表中的数据
                        foreach($entry122 as $key51 => $value51){
                            $entry123[] = $value51['score'];
                        }
                        $cha12 = array_sum($entry123);
                        $fcount12 = count($score2);
                        $fsum12 = $fcount12 * 90 + $cha12;
                        $pfuz12 = round($fsum12 / $fcount12,2);
                    }elseif(empty($entry122)){
                        // 计算detail表中的数据
                        foreach($detail122 as $key52 => $value52){
                            $detail123[] = $value52['score'];
                        }
                        $cha12 = array_sum($detail123);
                        $fcount12 = count($score2);
                        $fsum12 = $fcount12 * 90 + $cha12;
                        $pfuz12 = round($fsum12 / $fcount12,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail122 as $key53 => $value53){
                            $detail123[] = $value53['score'];
                        }
                        foreach($entry122 as $key53 => $value53){
                            $entry123[] = $value53['score'];
                        }
                        $chaz1221 = array_sum($detail123);
                        $chaz1222 = array_sum($entry123);
                        $cha12 = $chaz1221 + $chaz1222;
                        $fcount12 = count($score2);
                        $fsum12 = $fcount12 * 90 + $cha12;
                        $pfuz12 = round($fsum12 / $fcount12,2);
                    }
                }
                // 十二月 结束
                $yuan['11'] = $pyuan12;
                $xinz['11'] = $pxinz12;
                $fuz['11'] = $pfuz12;
                $yuane = implode(',',$yuan);
                $xinz = implode(',',$xinz);
                $fuz = implode(',',$fuz);
            // 板块二 结束
            
            // 板块三 开始
                // 员额法官
                foreach($score0 as $k3 => $v3){
                    $worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
                    foreach($worker as $k4 => $v4){
                        $yuan1[$k3]['worker_name'] = $v4['worker_name'];
                    }
                    $yuan1[$k3]['sum'] = $v3['sum'];
                }
                // 排序
                $sums = array();
                foreach($yuan1 as $li){
                    $sums[] = $li['sum'];
                }
                array_multisort($sums,SORT_DESC,$yuan1);
                $yname1 = 0;
                $ysum1 = 0;
                $b = count($yuan1);
                for($i=0;$i<$b;$i++){
                    $yname1 .= $yuan1[$i]['worker_name'] . ',';
                    $ysum1 .= $yuan1[$i]['sum'] . ',';
                }
                $yname1 = substr($yname1,1);
                $ysum1 = substr($ysum1,1);
                $yname = rtrim($yname1,',');
                $ysum = rtrim($ysum1,',');
            // 板块三 结束
            
            // 板块四 开始
                // 部门 
                $team1 = M('team')->order('team_id asc')->select();
                foreach($team1 as $key => $value){
                    $team_name[] = $value['team_name'];
                    $worker[$key] = M('worker')->where('team_id='.$value['team_id'])->select();
                }
                $team = implode(',',$team_name); // 部门名称
                foreach($worker as $key1 => $value1){
                    foreach($value1 as $key2 => $value2){
                        $bum[$key1][] = $value2['worker_id']; // 每个部门所有人员id
                    }
                }
                foreach($score as $key3 => $value3){
                    $sworker[$key3] = $value3['worker_id']; // 最新考核表下考核人员
                }
                foreach($bum as $key4 => $value4){
                    $bum1[$key4] = array_intersect($sworker,$value4); // 每个部门考核人员
                    $bumcount[$key4] = count($value4); // 每个部门人数
                }
                // var_dump($bumcount);die;
                foreach($bum1 as $key5 => $value5){
                    if(empty($value5)){
                        $bumen1[] = $key5; // 考核人员为空的部门
                        foreach($team_name as $key6 => $value6){
                            foreach($bumen1 as $key7 => $value7){
                                if($key6 == $value7){
                                    $pbumen1[$key5]['team_name'] = $value6; // 考核人员为空的部门
                                    $pbumen1[$key5]['fen'] = 0; // 考核人员为空的部门平均分数
                                }
                            }
                        }
                    }else{
                        $bumen2[] = $key5; // 考核人员不为空的部门
                        $brenyuan[$key5] = $value5; // 考核部门不为空的部门人员id
                        foreach($brenyuan as $key8 => $value8){
                            foreach($value8 as $key9 => $value9){
                                foreach($score as $key10 => $value10){
                                    $kaohe[$key10]['worker_id'] = $value10['worker_id'];
                                    $kaohe[$key10]['score_id'] = $value10['id'];
                                    if($value9 == $value10['worker_id']){
                                        $kaohe[$key10]['team_id'] = $key8;
                                    }
                                }
                            }
                        }
                    }
                }
                // echo "<pre>";
                // var_dump($bumen2);
                // echo "</pre>";die;
                foreach($kaohe as $key11 => $value11){
                    $khscore_id[] = $value11['score_id'];
                    $tiao['score_id'] = array('in',$khscore_id);
                    $tiao['ktime'] = $ktime;
                }
                $detail4 = M('detail')->where($tiao)->select();
                $entry4 = M('entry')->where($tiao)->select();
                if(empty($detail4) && empty($entry)){
                    foreach($kaohe as $key12 => $value12){
                        $kaohe[$key12]['sum'] = 90;
                    }
                }elseif(empty($detail4)){
                    // 计算entry表中的数据
                    foreach($entry4 as $k4 => $v4){
                        $scor3[] = $v4['score_id'];
                    }
                    $scor4 = array_unique($scor3);
                    foreach($scor4 as $k5 => $v5){
                        $res2[$k5]['id'] = $v5;
                        $tj1['score_id'] = $v5;
                        // $tj1['mtime'] = array('in',$ctime2);
                        $tj1['ktime'] = $ktime;
                        $etry1[] = M('entry')->where($tj1)->select();
                    }
                    foreach($scor4 as $k5 => $v5){
                        foreach($etry1 as $k6 => $v6){
                            foreach($v6 as $k7 => $v7){
                                if($v5 == $v7['score_id']){
                                    $res2[$k5]['cha'] += $v7['score'];
                                }
                            }
                        }
                    }
                    foreach($kaohe as $k9 => $v9){
                        $kaohe[$k9]['sum'] = 90;
                        foreach($res2 as $k8 => $v8){
                            if($v8['id'] == $v9['score_id']){
                                $kaohe[$k9]['sum'] = 90 + $v8['cha'];
                            }
                        }
                    }
                }elseif(empty($entry4)){
                    // 计算detail表中的数据
                    foreach($detail4 as $k1 => $v1){
                        $scor1[] = $v1['score_id'];
                    }
                    $scor2 = array_unique($scor1);
                    foreach($scor2 as $k2 => $v2){
                        $res1[$k2]['id'] = $v2;
                        $tj['score_id'] = $v2;
                        // $tj['mtime'] = array('in',$ctime1);
                        $tj['ktime'] = $ktime;
                        $detil1[] = M('detail')->where($tj)->select();
                    }
                    foreach($scor2 as $k2 => $v2){
                        foreach($detil1 as $k8 => $v8){
                            foreach($v8 as $k9 => $v9){
                                if($v2 == $v9['score_id']){
                                    $res1[$k2]['cha'] += $v9['score'];
                                }
                            }
                        }
                    }
                    foreach($kaohe as $k9 => $v9){
                        $kaohe[$k9]['sum'] = 90;
                        foreach($res1 as $k7 => $v7){
                            if($v7['id'] == $v9['score_id']){
                                $kaohe[$k9]['sum'] = 90 + $v7['cha'];
                            }
                        }
                    }                               
                }else{
                    // 计算detail表和entry表中的数据和
                    foreach($detail4 as $k1 => $v1){
                        $scor1[] = $v1['score_id'];
                    }
                    $scor2 = array_unique($scor1);
                    // var_dump($scor2);die;
                    foreach($scor2 as $k2 => $v2){
                        $res1[$k2]['id'] = $v2;
                        $tj['score_id'] = $v2;
                        // $tj['mtime'] = array('in',$ctime1);
                        $tj['ktime'] = $ktime;
                        $detil1[] = M('detail')->where($tj)->select();
                    }
                    foreach($scor2 as $k2 => $v2){
                        foreach($detil1 as $k8 => $v8){
                            foreach($v8 as $k9 => $v9){
                                if($v2 == $v9['score_id']){
                                    $res1[$k2]['cha'] += $v9['score'];
                                }
                            }
                        }
                    }
                    // echo "<pre>";
                    // var_dump($res1);
                    // echo "</pre>";die;
                    foreach($entry4 as $k4 => $v4){
                        $scor3[] = $v4['score_id'];
                    }
                    $scor4 = array_unique($scor3);
                    // var_dump($score4);die;
                    foreach($scor4 as $k5 => $v5){
                        $res2[$k5]['id'] = $v5;
                        $tj1['score_id'] = $v5;
                        // $tj1['mtime'] = array('in',$ctime2);
                        $tj1['ktime'] = $ktime;
                        $etry1[] = M('entry')->where($tj1)->select();
                    }
                    foreach($scor4 as $k5 => $v5){
                        foreach($etry1 as $k6 => $v6){
                            foreach($v6 as $k7 => $v7){
                                if($v5 == $v7['score_id']){
                                    $res2[$k5]['cha'] += $v7['score'];
                                }
                            }
                        }
                    }
                    // echo "<pre>";
                    // var_dump($res2);
                    // echo "</pre>";die;
                    $lis = array_merge_recursive($res1,$res2);
                    foreach($lis as $key => $val){
                        $deen[] = $val['id'];
                    }
                    $deen1 = array_unique($deen);
                    foreach($lis as $key1 => $val1){
                        foreach($deen1 as $key2 => $val2){
                            if($val2 == $val1['id']){
                                $li3[$key2]['id'] = $val1['id'];
                                $li3[$key2]['cha'] += $val1['cha'];
                            }
                        }
                    }
                    // echo "<pre>";
                    // var_dump($li3);
                    // echo "</pre>";die;
                    foreach($kaohe as $key3 => $val3){
                        $kaohe[$key3]['sum'] = 90;
                        foreach($li3 as $key4 => $val4){
                            if($val4['id'] == $val3['score_id']){
                                $kaohe[$key3]['sum'] = 90 + $val4['cha'];
                            }
                        }
                    }
                }
                // echo "<pre>";
                // var_dump($kaohe);
                // echo "</pre>";die;
                foreach($bumen2 as $key12 => $value12){
                    foreach($kaohe as $key13 => $value13){
                        if($value12 == $value13['team_id']){
                            $pbumen2[$value12] += $value13['sum']; // 各部门总分数
                        }   
                    }
                    foreach($pbumen2 as $key14 => $value14){
                        foreach($team_name as $key16 => $value16){
                            if($key14 == $key16){
                                $pbumen3[$key14]['team_name'] = $value16;
                            }
                        }
                        foreach($bumcount as $key15 => $value15){
                            if($key14 == $key15){
                                $pbumen3[$key14]['fen'] = round($value14 / $value15,2);
                            }
                        }
                    }
                }
                $pbumen4 = $pbumen1 + $pbumen3;
                ksort($pbumen4);
                foreach($pbumen4 as $key17 => $value17){
                    $pb_name1[] = $value17['team_name'];
                    $pb_fen1[] = $value17['fen'];
                }
                $pb_name = implode(',',$pb_name1);
                $pb_fen = implode(',',$pb_fen1);
                $month = '年';
            // 板块四 结束
                $this->assign('ktime',$ktime); 
            }else{
                $count = count($score); // 最新考核表下的所有人
                $posts = M('posts')->where('parent_id=0')->order('posts_id asc')->select();
            // 板块一 开始
                // 员额法官
                $posts0 = M('posts')->where('parent_id='.$posts['0']['posts_id'])->select();
                foreach($posts0 as $k0 => $v0){
                    $posts00[] = $v0['posts_id'];
                }
                $map0['posts_id'] = array('in',$posts00);
                $map0['test_time'] = $ktime;
                $score0 = M('score')->where($map0)->select();
                // var_dump($score0);die;
                $count0 = count($score0);
                $mp0['ktime'] = $ktime1;
                $mp0['posts'] = $posts['0']['posts_id'];
                $class0 = M('class')->where($mp0)->order('class_id asc')->select();
                foreach($score0 as $key0 => $val0){
                    if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
                        $sum01[] = $val0['sum'];
                        $count01 = count($sum01);
                        $bfb = $count01 / $count0 * '100%';
                        $bfb01 = round($bfb,2);
                    }elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
                        $sum02[] = $val0['sum'];
                        $count02 = count($sum02);
                        $bfb = $count02 / $count0 * '100%';
                        $bfb02 = round($bfb,2);
                    }elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
                        $sum03[] = $val0['sum'];
                        $count03 = count($sum03);
                        $bfb = $count03 / $count0 * '100%';
                        $bfb03 = round($bfb,2);
                    }elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
                        $sum04[] = $val0['sum'];
                        $count04 = count($sum04);
                        $bfb = $count04 / $count0 * '100%';
                        $bfb04 = round($bfb,2);
                    }
                }
                if(empty($bfb01)){
                    $bfb01 = 0;
                }
                if(empty($bfb02)){
                    $bfb02 = 0;
                }
                if(empty($bfb03)){
                    $bfb03 = 0;
                }
                if(empty($bfb04)){
                    $bfb04 = 0;
                }
                $list0['0'] = $bfb01;
                $list0['1'] = $bfb02;
                $list0['2'] = $bfb03;
                $list0['3'] = $bfb04;
                // var_dump($list0);die;

                // 司法行政人员
                $posts1 = M('posts')->where('parent_id='.$posts['1']['posts_id'])->select();
                foreach($posts1 as $k1 => $v1){
                    $posts11[] = $v1['posts_id'];
                }
                $map1['posts_id'] = array('in',$posts11);
                $map1['test_time'] = $ktime;
                $score1 = M('score')->where($map1)->select();
                $count1 = count($score1);
                $mp1['ktime'] = $ktime1;
                $mp1['posts'] = $posts['1']['posts_id'];
                $class1 = M('class')->where($mp1)->order('class_id asc')->select();
                foreach($score1 as $key1 => $val1){
                    if($val1['sum'] >= $class1['0']['bottom'] && $val1['sum'] < $class1['0']['top']){
                        $sum11[] = $val1['sum'];
                        $count11 = count($sum11);
                        $bfb = $count11 / $count1 * '100%';
                        $bfb11 = round($bfb,2);
                    }elseif($val1['sum'] >= $class1['1']['bottom'] && $val1['sum'] < $class1['1']['top']){
                        $sum12[] = $val1['sum'];
                        $count12 = count($sum12);
                        $bfb = $count12 / $count1 * '100%';
                        $bfb12 = round($bfb,2);
                    }elseif($val1['sum'] >= $class1['2']['bottom'] && $val1['sum'] < $class1['2']['top']){
                        $sum13[] = $val1['sum'];
                        $count13 = count($sum13);
                        $bfb = $count13 / $count1 * '100%';
                        $bfb13 = round($bfb,2);
                    }elseif($val1['sum'] >= $class1['3']['bottom'] && $val1['sum'] < $class1['3']['top']){
                        $sum14[] = $val1['sum'];
                        $count14 = count($sum14);
                        $bfb = $count14 / $count1 * '100%';
                        $bfb14 = round($bfb,2);
                    }
                }
                if(empty($bfb11)){
                    $bfb11 = 0;
                }
                if(empty($bfb12)){
                    $bfb12 = 0;
                }
                if(empty($bfb13)){
                    $bfb13 = 0;
                }
                if(empty($bfb14)){
                    $bfb14 = 0;
                }
                $list1['0'] = $bfb11;
                $list1['1'] = $bfb12;
                $list1['2'] = $bfb13;
                $list1['3'] = $bfb14;

                // 司法辅助人员
                $posts2 = M('posts')->where('parent_id='.$posts['2']['posts_id'])->select();
                foreach($posts2 as $k2 => $v2){
                    $posts22[] = $v2['posts_id'];
                }
                $map2['posts_id'] = array('in',$posts22);
                $map2['test_time'] = $ktime;
                $score2 = M('score')->where($map2)->select();
                $count2 = count($score2);
                $mp2['ktime'] = $ktime1;
                $mp2['posts'] = $posts['2']['posts_id'];
                $class2 = M('class')->where($mp2)->order('class_id asc')->select();
                foreach($score2 as $key2 => $val2){
                    if($val2['sum'] >= $class2['0']['bottom'] && $val2['sum'] < $class2['0']['top']){
                        $sum21[] = $val2['sum'];
                        $count21 = count($sum21);
                        $bfb = $count21 / $count2 * '100%';
                        $bfb21 = round($bfb,2);
                    }elseif($val2['sum'] >= $class2['1']['bottom'] && $val2['sum'] < $class2['1']['top']){
                        $sum22[] = $val2['sum'];
                        $count22 = count($sum22);
                        $bfb = $count22 / $count2 * '100%';
                        $bfb22 = round($bfb,2);
                    }elseif($val2['sum'] >= $class2['2']['bottom'] && $val2['sum'] < $class2['2']['top']){
                        $sum23[] = $val2['sum'];
                        $count23 = count($sum23);
                        $bfb = $count23 / $count2 * '100%';
                        $bfb23 = round($bfb,2);
                    }elseif($val2['sum'] >= $class2['3']['bottom'] && $val2['sum'] < $class2['3']['top']){
                        $sum24[] = $val2['sum'];
                        $count24 = count($sum24);
                        $bfb = $count24 / $count2 * '100%';
                        $bfb24 = round($bfb,2);
                    }
                }
                if(empty($bfb21)){
                    $bfb21 = 0;
                }
                if(empty($bfb22)){
                    $bfb22 = 0;
                }
                if(empty($bfb23)){
                    $bfb23 = 0;
                }
                if(empty($bfb24)){
                    $bfb24 = 0;
                }
                $list2['0'] = $bfb21;
                $list2['1'] = $bfb22;
                $list2['2'] = $bfb23;
                $list2['3'] = $bfb24;
                // 所有人分析
                $num1 = $count01 + $count11 + $count21;
                $bf1 = $num1 / $count * '100%';
                $bfb1 = round($bf1,2);
                $num2 = $count02 + $count12 + $count22;
                $bf2 = $num2 / $count * '100%';
                $bfb2 = round($bf2,2);
                $num3 = $count03 + $count13 + $count23;
                $bf3 = $num3 / $count * '100%';
                $bfb3 = round($bf3,2);
                $num4 = $count04 + $count14 + $count24;
                $bf4 = $num4 / $count * '100%';
                $bfb4 = round($bf4,2);
                if(empty($bfb1)){
                    $bfb1 = 0;
                }
                if(empty($bfb2)){
                    $bfb2 = 0;
                }
                if(empty($bfb3)){
                    $bfb3 = 0;
                }
                if(empty($bfb4)){
                    $bfb4 = 0;
                }
                $list['0'] = $bfb1;
                $list['1'] = $bfb2;
                $list['2'] = $bfb3;
                $list['3'] = $bfb4;
                $list0 = implode(',',$list0);
                $list1 = implode(',',$list1);
                $list2 = implode(',',$list2);
                $list = implode(',',$list);
            // 板块一 结束

            // 板块二 开始
                // 一月 开始 
                $ktime2 = $ktime1 . '-' . '01'; // 考核年月
                $ktime3 = strtotime($ktime2); // 考核年月时间戳 一月
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where0['ktime'] = $ktime;
                $where0['mtime'] = $ktime3;
                $where0['score_id'] = array('in',$yuan_id);
                $where01['ktime'] = $ktime;
                $where01['mtime'] = $ktime2;
                $where01['score_id'] = array('in',$yuan_id);
                $detail = M('detail')->where($where0)->select();
                $entry = M('entry')->where($where01)->select();
                if(empty($detail) && empty($entry)){
                    // 默认值
                    $ycount0 = count($score0);
                    $ysum0 = $ycount0 * 90;
                    $pyuan01 = $ysum0 / $ycount0;
                }else{
                    if(empty($detail)){
                        // 计算entry表中的数据
                        foreach($entry as $key31 => $value31){
                            $entry01[] = $value31['score'];
                        }
                        $cha01 = array_sum($entry01);
                        $ycount0 = count($score0);
                        $ysum0 = $ycount0 * 90 + $cha01;
                        $pyuan01 = round($ysum0 / $ycount0,2);
                    }elseif(empty($entry)){
                        // 计算detail表中的数据
                        foreach($detail as $key32 => $value32){
                            $detail01[] = $value32['score'];
                        }
                        $cha01 = array_sum($detail01);
                        $ycount0 = count($score0);
                        $ysum0 = $ycount0 * 90 + $cha01;
                        $pyuan01 = round($ysum0 / $ycount0,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail as $key33 => $value33){
                            $detail01[] = $value33['score'];
                        }
                        foreach($entry as $key33 => $value33){
                            $entry01[] = $value33['score'];
                        }
                        $chaz011 = array_sum($detail01);
                        $chaz012 = array_sum($entry01);
                        $cha01 = $chaz011 + $chaz012;
                        $ycount0 = count($score0);
                        $ysum0 = $ycount0 * 90 + $cha01;
                        $pyuan01 = round($ysum0 / $ycount0,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where1['ktime'] = $ktime;
                $where1['mtime'] = $ktime3;
                $where1['score_id'] = array('in',$xinz_id);
                $where11['ktime'] = $ktime;
                $where11['mtime'] = $ktime2;
                $where11['score_id'] = array('in',$xinz_id);
                $detail1 = M('detail')->where($where1)->select();
                $entry1 = M('entry')->where($where11)->select();
                if(empty($detail1) && empty($entry1)){
                    // 默认值
                    $xcount1 = count($score1);
                    $xsum1 = $xcount1 * 90;
                    $pxinz11 = $xsum1 / $xcount1;
                }else{
                    if(empty($detail1)){
                        // 计算entry表中的数据
                        foreach($entry1 as $key41 => $value41){
                            $entry11[] = $value41['score'];
                        }
                        $cha11 = array_sum($entry11);
                        $xcount1 = count($score1);
                        $xsum1 = $xcount1 * 90 + $cha11;
                        $pxinz11 = round($xsum1 / $xcount1,2);
                    }elseif(empty($entry1)){
                        // 计算detail表中的数据
                        foreach($detail1 as $key42 => $value42){
                            $detail11[] = $value42['score'];
                        }
                        $cha11 = array_sum($detail11);
                        $xcount1 = count($score1);
                        $xsum1 = $xcount1 * 90 + $cha11;
                        $pxinz11 = round($xsum1 / $xcount1,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail1 as $key43 => $value43){
                            $detail11[] = $value43['score'];
                        }
                        foreach($entry1 as $key43 => $value43){
                            $entry11[] = $value43['score'];
                        }
                        $chaz111 = array_sum($detail11);
                        $chaz112 = array_sum($entry11);
                        $cha11 = $chaz111 + $chaz112;
                        $xcount1 = count($score1);
                        $xsum1 = $xcount1 * 90 + $cha11;
                        $pxinz11 = round($xsum1 / $xcount1,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where2['ktime'] = $ktime;
                $where2['mtime'] = $ktime3;
                $where2['score_id'] = array('in',$fuz_id);
                $where21['ktime'] = $ktime;
                $where21['mtime'] = $ktime2;
                $where21['score_id'] = array('in',$fuz_id);
                $detail2 = M('detail')->where($where2)->select();
                $entry2 = M('entry')->where($where21)->select();
                if(empty($detail2) && empty($entry2)){
                    // 默认值
                    $fcount2 = count($score2);
                    $fsum2 = $fcount2 * 90;
                    $pfuz22 = $fsum2 / $fcount2;
                }else{
                    if(empty($detail2)){
                        // 计算entry表中的数据
                        foreach($entry2 as $key51 => $value51){
                            $entry22[] = $value51['score'];
                        }
                        $cha21 = array_sum($entry22);
                        $fcount2 = count($score2);
                        $fsum2 = $fcount2 * 90 + $cha21;
                        $pfuz22 = round($fsum2 / $fcount2,2);
                    }elseif(empty($entry2)){
                        // 计算detail表中的数据
                        foreach($detail2 as $key52 => $value52){
                            $detail22[] = $value52['score'];
                        }
                        $cha22 = array_sum($detail22);
                        $fcount2 = count($score2);
                        $fsum2 = $fcount2 * 90 + $cha22;
                        $pfuz22 = round($fsum2 / $fcount2,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail2 as $key53 => $value53){
                            $detail22[] = $value53['score'];
                        }
                        foreach($entry2 as $key53 => $value53){
                            $entry22[] = $value53['score'];
                        }
                        $chaz211 = array_sum($detail22);
                        $chaz212 = array_sum($entry22);
                        $cha22 = $chaz211 + $chaz212;
                        $fcount2 = count($score2);
                        $fsum2 = $fcount2 * 90 + $cha22;
                        $pfuz22 = round($fsum2 / $fcount2,2);
                    }
                }
                // 一月 结束
                $yuan['0'] = $pyuan01;
                $xinz['0'] = $pxinz11;
                $fuz['0'] = $pfuz22;

                // 二月 开始
                for($i = 1;$i <= 2;$i++){
                    $a[] = $i;
                }
                foreach($a as $k => $v){
                    $ktime4[] = $ktime1 . '-0' . $v;
                    $ktime5[] = strtotime($ktime1 . '-' . $v);
                }
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where2['ktime'] = $ktime;
                $where2['mtime'] = array('in',$ktime5);
                $where2['score_id'] = array('in',$yuan_id);
                $where21['ktime'] = $ktime;
                $where21['mtime'] = array('in',$ktime4);
                $where21['score_id'] = array('in',$yuan_id);
                $detail2 = M('detail')->where($where2)->select();
                $entry2 = M('entry')->where($where21)->select();
                if(empty($detail2) && empty($entry2)){
                    // 默认值
                    $ycount2 = count($score0);
                    $ysum2 = $ycount2 * 90;
                    $pyuan21 = $ysum2 / $ycount2;
                }else{
                    if(empty($detail2)){
                        // 计算entry表中的数据
                        foreach($entry2 as $key31 => $value31){
                            $entry21[] = $value31['score'];
                        }
                        $cha21 = array_sum($entry21);
                        $ycount2 = count($score0);
                        $ysum2 = $ycount2 * 90 + $cha21;
                        $pyuan21 = round($ysum2 / $ycount2,2);
                    }elseif(empty($entry2)){
                        // 计算detail表中的数据
                        foreach($detail2 as $key32 => $value32){
                            $detail21[] = $value32['score'];
                        }
                        $cha21 = array_sum($detail21);
                        $ycount2 = count($score0);
                        $ysum2 = $ycount2 * 90 + $cha21;
                        $pyuan21 = round($ysum2 / $ycount2,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail2 as $key33 => $value33){
                            $detail21[] = $value33['score'];
                        }
                        foreach($entry2 as $key33 => $value33){
                            $entry21[] = $value33['score'];
                        }
                        $chaz211 = array_sum($detail21);
                        $chaz212 = array_sum($entry21);
                        $cha21 = $chaz211 + $chaz212;
                        $ycount2 = count($score0);
                        $ysum2 = $ycount2 * 90 + $cha21;
                        $pyuan21 = round($ysum2 / $ycount2,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where22['ktime'] = $ktime;
                $where22['mtime'] = array('in',$ktime5);
                $where22['score_id'] = array('in',$xinz_id);
                $where23['ktime'] = $ktime;
                $where23['mtime'] = array('in',$ktime4);
                $where23['score_id'] = array('in',$xinz_id);
                $detail21 = M('detail')->where($where22)->select();
                $entry21 = M('entry')->where($where23)->select();
                if(empty($detail21) && empty($entry21)){
                    // 默认值
                    $xcount21 = count($score1);
                    $xsum21 = $xcount21 * 90;
                    $pxinz21 = $xsum21 / $xcount21;
                }else{
                    if(empty($detail21)){
                        // 计算entry表中的数据
                        foreach($entry21 as $key41 => $value41){
                            $entry22[] = $value41['score'];
                        }
                        $cha21 = array_sum($entry22);
                        $xcount21 = count($score1);
                        $xsum21 = $xcount21 * 90 + $cha21;
                        $pxinz21 = round($xsum21 / $xcount21,2);
                    }elseif(empty($entry21)){
                        // 计算detail表中的数据
                        foreach($detail21 as $key42 => $value42){
                            $detail22[] = $value42['score'];
                        }
                        $cha22 = array_sum($detail22);
                        $xcount21 = count($score1);
                        $xsum21 = $xcount21 * 90 + $cha22;
                        $pxinz21 = round($xsum21 / $xcount21,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail21 as $key43 => $value43){
                            $detail22[] = $value43['score'];
                        }
                        foreach($entry21 as $key43 => $value43){
                            $entry22[] = $value43['score'];
                        }
                        $chaz211 = array_sum($detail22);
                        $chaz212 = array_sum($entry22);
                        $cha22 = $chaz211 + $chaz212;
                        $xcount21 = count($score1);
                        $xsum21 = $xcount21 * 90 + $cha22;
                        $pxinz21 = round($xsum21 / $xcount21,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where24['ktime'] = $ktime;
                $where24['mtime'] = array('in',$ktime5);
                $where24['score_id'] = array('in',$fuz_id);
                $where25['ktime'] = $ktime;
                $where25['mtime'] = array('in',$ktime4);
                $where25['score_id'] = array('in',$fuz_id);
                $detail22 = M('detail')->where($where24)->select();
                $entry22 = M('entry')->where($where25)->select();
                if(empty($detail22) && empty($entry22)){
                    // 默认值
                    $fcount22 = count($score2);
                    $fsum22 = $fcount22 * 90;
                    $pfuz22 = $fsum22 / $fcount22;
                }else{
                    if(empty($detail22)){
                        // 计算entry表中的数据
                        foreach($entry22 as $key51 => $value51){
                            $entry23[] = $value51['score'];
                        }
                        $cha22 = array_sum($entry23);
                        $fcount22 = count($score2);
                        $fsum22 = $fcount22 * 90 + $cha22;
                        $pfuz22 = round($fsum22 / $fcount22,2);
                    }elseif(empty($entry22)){
                        // 计算detail表中的数据
                        foreach($detail22 as $key52 => $value52){
                            $detail23[] = $value52['score'];
                        }
                        $cha22 = array_sum($detail23);
                        $fcount22 = count($score2);
                        $fsum22 = $fcount22 * 90 + $cha22;
                        $pfuz22 = round($fsum22 / $fcount22,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail22 as $key53 => $value53){
                            $detail23[] = $value53['score'];
                        }
                        foreach($entry22 as $key53 => $value53){
                            $entry23[] = $value53['score'];
                        }
                        $chaz221 = array_sum($detail23);
                        $chaz222 = array_sum($entry23);
                        $cha22 = $chaz221 + $chaz222;
                        $fcount22 = count($score2);
                        $fsum22 = $fcount22 * 90 + $cha22;
                        $pfuz22 = round($fsum22 / $fcount22,2);
                    }
                }
                // 二月 结束
                $yuan['1'] = $pyuan21;
                $xinz['1'] = $pxinz21;
                $fuz['1'] = $pfuz22;
                
                // 三月 开始
                for($i = 1;$i <= 3;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime6[] = $ktime1 . '-0' . $v;
                    $ktime7[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where30['ktime'] = $ktime;
                $where30['mtime'] = array('in',$ktime7);
                $where30['score_id'] = array('in',$yuan_id);
                $where31['ktime'] = $ktime;
                $where31['mtime'] = array('in',$ktime6);
                $where31['score_id'] = array('in',$yuan_id);
                $detail3 = M('detail')->where($where30)->select();
                $entry3 = M('entry')->where($where31)->select();
                if(empty($detail3) && empty($entry3)){
                    // 默认值
                    $ycount3 = count($score0);
                    $ysum3 = $ycount3 * 90;
                    $pyuan3 = $ysum3 / $ycount3;
                }else{
                    if(empty($detail3)){
                        // 计算entry表中的数据
                        foreach($entry3 as $key31 => $value31){
                            $entry31[] = $value31['score'];
                        }
                        $cha3 = array_sum($entry31);
                        $ycount3 = count($score0);
                        $ysum3= $ycount3 * 90 + $cha3;
                        $pyuan3 = round($ysum3 / $ycount3,2);
                    }elseif(empty($entry3)){
                        // 计算detail表中的数据
                        foreach($detail3 as $key32 => $value32){
                            $detail31[] = $value32['score'];
                        }
                        $cha3 = array_sum($detail31);
                        $ycount3 = count($score0);
                        $ysum3 = $ycount3 * 90 + $cha3;
                        $pyuan3 = round($ysum3 / $ycount3,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail3 as $key33 => $value33){
                            $detail31[] = $value33['score'];
                        }
                        foreach($entry3 as $key33 => $value33){
                            $entry31[] = $value33['score'];
                        }
                        $chaz311 = array_sum($detail31);
                        $chaz312 = array_sum($entry31);
                        $cha3 = $chaz311 + $chaz312;
                        $ycount3 = count($score0);
                        $ysum3 = $ycount3 * 90 + $cha3;
                        $pyuan3 = round($ysum3 / $ycount3,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where32['ktime'] = $ktime;
                $where32['mtime'] = array('in',$ktime7);
                $where32['score_id'] = array('in',$xinz_id);
                $where33['ktime'] = $ktime;
                $where33['mtime'] = array('in',$ktime6);
                $where33['score_id'] = array('in',$xinz_id);
                $detail31 = M('detail')->where($where32)->select();
                $entry31 = M('entry')->where($where33)->select();
                if(empty($detail31) && empty($entry31)){
                    // 默认值
                    $xcount3 = count($score1);
                    $xsum3 = $xcount3 * 90;
                    $pxinz3 = $xsum3 / $xcount3;
                }else{
                    if(empty($detail31)){
                        // 计算entry表中的数据
                        foreach($entry31 as $key41 => $value41){
                            $entry32[] = $value41['score'];
                        }
                        $cha3 = array_sum($entry32);
                        $xcount3 = count($score1);
                        $xsum3 = $xcount3 * 90 + $cha3;
                        $pxinz3 = round($xsum3 / $xcount3,2);
                    }elseif(empty($entry31)){
                        // 计算detail表中的数据
                        foreach($detail31 as $key42 => $value42){
                            $detail32[] = $value42['score'];
                        }
                        $cha3 = array_sum($detail32);
                        $xcount3 = count($score1);
                        $xsum3 = $xcount3 * 90 + $cha3;
                        $pxinz3 = round($xsum3 / $xcount3,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail31 as $key43 => $value43){
                            $detail32[] = $value43['score'];
                        }
                        foreach($entry31 as $key43 => $value43){
                            $entry32[] = $value43['score'];
                        }
                        $chaz311 = array_sum($detail32);
                        $chaz312 = array_sum($entry32);
                        $cha3 = $chaz311 + $chaz312;
                        $xcount3 = count($score1);
                        $xsum3 = $xcount3 * 90 + $cha3;
                        $pxinz3 = round($xsum3 / $xcount3,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where34['ktime'] = $ktime;
                $where34['mtime'] = array('in',$ktime7);
                $where34['score_id'] = array('in',$fuz_id);
                $where35['ktime'] = $ktime;
                $where35['mtime'] = array('in',$ktime6);
                $where35['score_id'] = array('in',$fuz_id);
                $detail32 = M('detail')->where($where34)->select();
                $entry32 = M('entry')->where($where35)->select();
                if(empty($detail32) && empty($entry32)){
                    // 默认值
                    $fcount3 = count($score2);
                    $fsum3 = $fcount3 * 90;
                    $pfuz3 = $fsum3 / $fcount3;
                }else{
                    if(empty($detail32)){
                        // 计算entry表中的数据
                        foreach($entry32 as $key51 => $value51){
                            $entry33[] = $value51['score'];
                        }
                        $cha3 = array_sum($entry33);
                        $fcount3 = count($score2);
                        $fsum3 = $fcount3 * 90 + $cha3;
                        $pfuz3 = round($fsum3 / $fcount3,2);
                    }elseif(empty($entry32)){
                        // 计算detail表中的数据
                        foreach($detail32 as $key52 => $value52){
                            $detail33[] = $value52['score'];
                        }
                        $cha3 = array_sum($detail33);
                        $fcount3 = count($score2);
                        $fsum3 = $fcount3 * 90 + $cha3;
                        $pfuz3 = round($fsum3 / $fcount3,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail32 as $key53 => $value53){
                            $detail33[] = $value53['score'];
                        }
                        foreach($entry32 as $key53 => $value53){
                            $entry33[] = $value53['score'];
                        }
                        $chaz321 = array_sum($detail33);
                        $chaz322 = array_sum($entry33);
                        $cha3 = $chaz321 + $chaz322;
                        $fcount3 = count($score2);
                        $fsum3 = $fcount3 * 90 + $cha3;
                        $pfuz3 = round($fsum3 / $fcount3,2);
                    }
                }
                // 三月 结束
                $yuan['2'] = $pyuan3;
                $xinz['2'] = $pxinz3;
                $fuz['2'] = $pfuz3;
                
                // 四月 开始
                for($i = 1;$i <= 4;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime8[] = $ktime1 . '-0' . $v;
                    $ktime9[] = strtotime($ktime1 . '-' . $v);
                }
                // var_dump($ktime6);
                // var_dump($ktime7);die;
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where40['ktime'] = $ktime;
                $where40['mtime'] = array('in',$ktime9);
                $where40['score_id'] = array('in',$yuan_id);
                $where41['ktime'] = $ktime;
                $where41['mtime'] = array('in',$ktime8);
                $where41['score_id'] = array('in',$yuan_id);
                $detail4 = M('detail')->where($where40)->select();
                $entry4 = M('entry')->where($where41)->select();
                if(empty($detail4) && empty($entry4)){
                    // 默认值
                    $ycount4 = count($score0);
                    $ysum4 = $ycount4 * 90;
                    $pyuan4 = $ysum4 / $ycount4;
                }else{
                    if(empty($detail4)){
                        // 计算entry表中的数据
                        foreach($entry4 as $key31 => $value31){
                            $entry41[] = $value31['score'];
                        }
                        $cha4 = array_sum($entry41);
                        $ycount4 = count($score0);
                        $ysum4 = $ycount4 * 90 + $cha4;
                        $pyuan4 = round($ysum4 / $ycount4,2);
                    }elseif(empty($entry4)){
                        // 计算detail表中的数据
                        foreach($detail4 as $key32 => $value32){
                            $detail41[] = $value32['score'];
                        }
                        $cha4 = array_sum($detail31);
                        $ycount4 = count($score0);
                        $ysum4 = $ycount4 * 90 + $cha4;
                        $pyuan4 = round($ysum4 / $ycount4,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail4 as $key33 => $value33){
                            $detail41[] = $value33['score'];
                        }
                        foreach($entry4 as $key33 => $value33){
                            $entry41[] = $value33['score'];
                        }
                        $chaz411 = array_sum($detail41);
                        $chaz412 = array_sum($entry41);
                        $cha4 = $chaz411 + $chaz412;
                        $ycount4 = count($score0);
                        $ysum4 = $ycount4 * 90 + $cha4;
                        $pyuan4 = round($ysum4 / $ycount4,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where42['ktime'] = $ktime;
                $where42['mtime'] = array('in',$ktime9);
                $where42['score_id'] = array('in',$xinz_id);
                $where43['ktime'] = $ktime;
                $where43['mtime'] = array('in',$ktime8);
                $where43['score_id'] = array('in',$xinz_id);
                $detail41 = M('detail')->where($where42)->select();
                $entry41 = M('entry')->where($where43)->select();
                if(empty($detail41) && empty($entry41)){
                    // 默认值
                    $xcount4 = count($score1);
                    $xsum4 = $xcount4 * 90;
                    $pxinz4 = $xsum4 / $xcount4;
                }else{
                    if(empty($detail41)){
                        // 计算entry表中的数据
                        foreach($entry41 as $key41 => $value41){
                            $entry42[] = $value41['score'];
                        }
                        $cha4 = array_sum($entry42);
                        $xcount4 = count($score1);
                        $xsum4 = $xcount4 * 90 + $cha4;
                        $pxinz4 = round($xsum4 / $xcount4,2);
                    }elseif(empty($entry41)){
                        // 计算detail表中的数据
                        foreach($detail41 as $key42 => $value42){
                            $detail42[] = $value42['score'];
                        }
                        $cha4 = array_sum($detail42);
                        $xcount4 = count($score1);
                        $xsum4 = $xcount4 * 90 + $cha4;
                        $pxinz4 = round($xsum4 / $xcount4,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail41 as $key43 => $value43){
                            $detail42[] = $value43['score'];
                        }
                        foreach($entry41 as $key43 => $value43){
                            $entry42[] = $value43['score'];
                        }
                        $chaz411 = array_sum($detail42);
                        $chaz412 = array_sum($entry42);
                        $cha4 = $chaz411 + $chaz412;
                        $xcount4 = count($score1);
                        $xsum4 = $xcount3 * 90 + $cha3;
                        $pxinz4 = round($xsum4 / $xcount4,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where44['ktime'] = $ktime;
                $where44['mtime'] = array('in',$ktime9);
                $where44['score_id'] = array('in',$fuz_id);
                $where45['ktime'] = $ktime;
                $where45['mtime'] = array('in',$ktime8);
                $where45['score_id'] = array('in',$fuz_id);
                $detail42 = M('detail')->where($where44)->select();
                $entry42 = M('entry')->where($where45)->select();
                if(empty($detail42) && empty($entry42)){
                    // 默认值
                    $fcount4 = count($score2);
                    $fsum4 = $fcount4 * 90;
                    $pfuz4 = $fsum4 / $fcount4;
                }else{
                    if(empty($detail42)){
                        // 计算entry表中的数据
                        foreach($entry42 as $key51 => $value51){
                            $entry43[] = $value51['score'];
                        }
                        $cha4 = array_sum($entry43);
                        $fcount4 = count($score2);
                        $fsum4 = $fcount4 * 90 + $cha4;
                        $pfuz4 = round($fsum4 / $fcount4,2);
                    }elseif(empty($entry42)){
                        // 计算detail表中的数据
                        foreach($detail42 as $key52 => $value52){
                            $detail43[] = $value52['score'];
                        }
                        $cha4 = array_sum($detail43);
                        $fcount4 = count($score2);
                        $fsum4 = $fcount4 * 90 + $cha4;
                        $pfuz4 = round($fsum4 / $fcount4,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail42 as $key53 => $value53){
                            $detail43[] = $value53['score'];
                        }
                        foreach($entry42 as $key53 => $value53){
                            $entry43[] = $value53['score'];
                        }
                        $chaz421 = array_sum($detail43);
                        $chaz422 = array_sum($entry43);
                        $cha4 = $chaz421 + $chaz422;
                        $fcount4 = count($score2);
                        $fsum4 = $fcount4 * 90 + $cha4;
                        $pfuz4 = round($fsum4 / $fcount4,2);
                    }
                }
                // 四月 结束
                $yuan['3'] = $pyuan4;
                $xinz['3'] = $pxinz4;
                $fuz['3'] = $pfuz4;

                // 五月 开始
                for($i = 1;$i <= 5;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime10[] = $ktime1 . '-0' . $v;
                    $ktime11[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where50['ktime'] = $ktime;
                $where50['mtime'] = array('in',$ktime11);
                $where50['score_id'] = array('in',$yuan_id);
                $where51['ktime'] = $ktime;
                $where51['mtime'] = array('in',$ktime10);
                $where51['score_id'] = array('in',$yuan_id);
                $detail5 = M('detail')->where($where50)->select();
                $entry5 = M('entry')->where($where51)->select();
                if(empty($detail5) && empty($entry5)){
                    // 默认值
                    $ycount5 = count($score0);
                    $ysum5 = $ycount5 * 90;
                    $pyuan5 = $ysum5 / $ycount5;
                }else{
                    if(empty($detail5)){
                        // 计算entry表中的数据
                        foreach($entry5 as $key31 => $value31){
                            $entry51[] = $value31['score'];
                        }
                        $cha5 = array_sum($entry51);
                        $ycount5 = count($score0);
                        $ysum5 = $ycount5 * 90 + $cha5;
                        $pyuan5 = round($ysum5 / $ycount5,2);
                    }elseif(empty($entry5)){
                        // 计算detail表中的数据
                        foreach($detail5 as $key32 => $value32){
                            $detail51[] = $value32['score'];
                        }
                        $cha5 = array_sum($detail51);
                        $ycount5 = count($score0);
                        $ysum5 = $ycount5 * 90 + $cha5;
                        $pyuan5 = round($ysum5 / $ycount5,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail5 as $key33 => $value33){
                            $detail51[] = $value33['score'];
                        }
                        foreach($entry5 as $key33 => $value33){
                            $entry51[] = $value33['score'];
                        }
                        $chaz511 = array_sum($detail51);
                        $chaz512 = array_sum($entry51);
                        $cha5 = $chaz511 + $chaz512;
                        $ycount5 = count($score0);
                        $ysum5 = $ycount5 * 90 + $cha5;
                        $pyuan5 = round($ysum5 / $ycount5,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where52['ktime'] = $ktime;
                $where52['mtime'] = array('in',$ktime11);
                $where52['score_id'] = array('in',$xinz_id);
                $where53['ktime'] = $ktime;
                $where53['mtime'] = array('in',$ktime10);
                $where53['score_id'] = array('in',$xinz_id);
                $detail51 = M('detail')->where($where52)->select();
                $entry51 = M('entry')->where($where53)->select();
                if(empty($detail51) && empty($entry51)){
                    // 默认值
                    $xcount5 = count($score1);
                    $xsum5 = $xcount5 * 90;
                    $pxinz5 = $xsum5 / $xcount5;
                }else{
                    if(empty($detail51)){
                        // 计算entry表中的数据
                        foreach($entry51 as $key41 => $value41){
                            $entry52[] = $value41['score'];
                        }
                        $cha5 = array_sum($entry52);
                        $xcount5 = count($score1);
                        $xsum5 = $xcount5 * 90 + $cha5;
                        $pxinz5 = round($xsum5 / $xcount5,2);
                    }elseif(empty($entry51)){
                        // 计算detail表中的数据
                        foreach($detail51 as $key42 => $value42){
                            $detail52[] = $value42['score'];
                        }
                        $cha5 = array_sum($detail52);
                        $xcount5 = count($score1);
                        $xsum5 = $xcount5 * 90 + $cha5;
                        $pxinz5 = round($xsum5 / $xcount5,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail51 as $key43 => $value43){
                            $detail52[] = $value43['score'];
                        }
                        foreach($entry51 as $key43 => $value43){
                            $entry52[] = $value43['score'];
                        }
                        $chaz511 = array_sum($detail52);
                        $chaz512 = array_sum($entry52);
                        $cha5 = $chaz511 + $chaz512;
                        $xcount5 = count($score1);
                        $xsum5 = $xcount5 * 90 + $cha5;
                        $pxinz5 = round($xsum5 / $xcount5,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where54['ktime'] = $ktime;
                $where54['mtime'] = array('in',$ktime11);
                $where54['score_id'] = array('in',$fuz_id);
                $where55['ktime'] = $ktime;
                $where55['mtime'] = array('in',$ktime10);
                $where55['score_id'] = array('in',$fuz_id);
                $detail52 = M('detail')->where($where54)->select();
                $entry52 = M('entry')->where($where55)->select();
                if(empty($detail52) && empty($entry52)){
                    // 默认值
                    $fcount5 = count($score2);
                    $fsum5 = $fcount5 * 90;
                    $pfuz5 = $fsum5 / $fcount5;
                }else{
                    if(empty($detail52)){
                        // 计算entry表中的数据
                        foreach($entry52 as $key51 => $value51){
                            $entry53[] = $value51['score'];
                        }
                        $cha5 = array_sum($entry53);
                        $fcount5 = count($score2);
                        $fsum5 = $fcount5 * 90 + $cha5;
                        $pfuz5 = round($fsum5 / $fcount5,2);
                    }elseif(empty($entry52)){
                        // 计算detail表中的数据
                        foreach($detail52 as $key52 => $value52){
                            $detail53[] = $value52['score'];
                        }
                        $cha5 = array_sum($detail53);
                        $fcount5 = count($score2);
                        $fsum5 = $fcount5 * 90 + $cha5;
                        $pfuz5 = round($fsum5 / $fcount5,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail52 as $key53 => $value53){
                            $detail53[] = $value53['score'];
                        }
                        foreach($entry52 as $key53 => $value53){
                            $entry53[] = $value53['score'];
                        }
                        $chaz521 = array_sum($detail53);
                        $chaz522 = array_sum($entry53);
                        $cha5 = $chaz521 + $chaz522;
                        $fcount5 = count($score2);
                        $fsum5 = $fcount5 * 90 + $cha5;
                        $pfuz5 = round($fsum5 / $fcount5,2);
                    }
                }
                // 五月 结束
                $yuan['4'] = $pyuan5;
                $xinz['4'] = $pxinz5;
                $fuz['4'] = $pfuz5;

                // 六月 开始
                for($i = 1;$i <= 6;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime12[] = $ktime1 . '-0' . $v;
                    $ktime13[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where60['ktime'] = $ktime;
                $where60['mtime'] = array('in',$ktime13);
                $where60['score_id'] = array('in',$yuan_id);
                $where61['ktime'] = $ktime;
                $where61['mtime'] = array('in',$ktime12);
                $where61['score_id'] = array('in',$yuan_id);
                $detail6 = M('detail')->where($where60)->select();
                $entry6 = M('entry')->where($where61)->select();
                if(empty($detail6) && empty($entry6)){
                    // 默认值
                    $ycount6 = count($score0);
                    $ysum6 = $ycount6 * 90;
                    $pyuan6 = $ysum6 / $ycount6;
                }else{
                    if(empty($detail6)){
                        // 计算entry表中的数据
                        foreach($entry6 as $key31 => $value31){
                            $entry61[] = $value31['score'];
                        }
                        $cha6 = array_sum($entry61);
                        $ycount6 = count($score0);
                        $ysum6 = $ycount6 * 90 + $cha6;
                        $pyuan6 = round($ysum6 / $ycount6,2);
                    }elseif(empty($entry6)){
                        // 计算detail表中的数据
                        foreach($detail6 as $key32 => $value32){
                            $detail61[] = $value32['score'];
                        }
                        $cha6 = array_sum($detail61);
                        $ycount6 = count($score0);
                        $ysum6 = $ycount6 * 90 + $cha6;
                        $pyuan6 = round($ysum6 / $ycount6,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail6 as $key33 => $value33){
                            $detail61[] = $value33['score'];
                        }
                        foreach($entry6 as $key33 => $value33){
                            $entry61[] = $value33['score'];
                        }
                        $chaz611 = array_sum($detail61);
                        $chaz612 = array_sum($entry61);
                        $cha6 = $chaz611 + $chaz612;
                        $ycount6 = count($score0);
                        $ysum6 = $ycount6 * 90 + $cha6;
                        $pyuan6 = round($ysum6 / $ycount6,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where62['ktime'] = $ktime;
                $where62['mtime'] = array('in',$ktime13);
                $where62['score_id'] = array('in',$xinz_id);
                $where63['ktime'] = $ktime;
                $where63['mtime'] = array('in',$ktime12);
                $where63['score_id'] = array('in',$xinz_id);
                $detail61 = M('detail')->where($where62)->select();
                $entry61 = M('entry')->where($where63)->select();
                if(empty($detail61) && empty($entry61)){
                    // 默认值
                    $xcount6 = count($score1);
                    $xsum6 = $xcount6 * 90;
                    $pxinz6 = $xsum6 / $xcount6;
                }else{
                    if(empty($detail61)){
                        // 计算entry表中的数据
                        foreach($entry61 as $key41 => $value41){
                            $entry62[] = $value41['score'];
                        }
                        $cha6 = array_sum($entry62);
                        $xcount6 = count($score1);
                        $xsum6 = $xcount6 * 90 + $cha6;
                        $pxinz6 = round($xsum6 / $xcount6,2);
                    }elseif(empty($entry61)){
                        // 计算detail表中的数据
                        foreach($detail61 as $key42 => $value42){
                            $detail62[] = $value42['score'];
                        }
                        $cha6 = array_sum($detail62);
                        $xcount6 = count($score1);
                        $xsum6 = $xcount6 * 90 + $cha6;
                        $pxinz6 = round($xsum6 / $xcount6,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail61 as $key43 => $value43){
                            $detail62[] = $value43['score'];
                        }
                        foreach($entry61 as $key43 => $value43){
                            $entry62[] = $value43['score'];
                        }
                        $chaz611 = array_sum($detail62);
                        $chaz612 = array_sum($entry62);
                        $cha6 = $chaz611 + $chaz612;
                        $xcount6 = count($score1);
                        $xsum6 = $xcount6 * 90 + $cha6;
                        $pxinz6 = round($xsum6 / $xcount6,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where64['ktime'] = $ktime;
                $where64['mtime'] = array('in',$ktime13);
                $where64['score_id'] = array('in',$fuz_id);
                $where65['ktime'] = $ktime;
                $where65['mtime'] = array('in',$ktime12);
                $where65['score_id'] = array('in',$fuz_id);
                $detail62 = M('detail')->where($where64)->select();
                $entry62 = M('entry')->where($where65)->select();
                if(empty($detail62) && empty($entry62)){
                    // 默认值
                    $fcount6 = count($score2);
                    $fsum6 = $fcount6 * 90;
                    $pfuz6 = $fsum6 / $fcount6;
                }else{
                    if(empty($detail62)){
                        // 计算entry表中的数据
                        foreach($entry62 as $key51 => $value51){
                            $entry63[] = $value51['score'];
                        }
                        $cha6 = array_sum($entry63);
                        $fcount6 = count($score2);
                        $fsum6 = $fcount6 * 90 + $cha6;
                        $pfuz6 = round($fsum6 / $fcount6,2);
                    }elseif(empty($entry62)){
                        // 计算detail表中的数据
                        foreach($detail62 as $key52 => $value52){
                            $detail63[] = $value52['score'];
                        }
                        $cha6 = array_sum($detail63);
                        $fcount6 = count($score2);
                        $fsum6 = $fcount6 * 90 + $cha6;
                        $pfuz6 = round($fsum6 / $fcount6,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail62 as $key53 => $value53){
                            $detail63[] = $value53['score'];
                        }
                        foreach($entry62 as $key53 => $value53){
                            $entry63[] = $value53['score'];
                        }
                        $chaz621 = array_sum($detail63);
                        $chaz622 = array_sum($entry63);
                        $cha6 = $chaz621 + $chaz622;
                        $fcount6 = count($score2);
                        $fsum6 = $fcount6 * 90 + $cha6;
                        $pfuz6 = round($fsum6 / $fcount6,2);
                    }
                }
                // 六月 结束
                $yuan['5'] = $pyuan6;
                $xinz['5'] = $pxinz6;
                $fuz['5'] = $pfuz6;

                // 七月 开始
                for($i = 1;$i <= 7;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime14[] = $ktime1 . '-0' . $v;
                    $ktime15[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where70['ktime'] = $ktime;
                $where70['mtime'] = array('in',$ktime15);
                $where70['score_id'] = array('in',$yuan_id);
                $where71['ktime'] = $ktime;
                $where71['mtime'] = array('in',$ktime14);
                $where71['score_id'] = array('in',$yuan_id);
                $detail7 = M('detail')->where($where70)->select();
                $entry7 = M('entry')->where($where71)->select();
                if(empty($detail7) && empty($entry7)){
                    // 默认值
                    $ycount7 = count($score0);
                    $ysum7 = $ycount7 * 90;
                    $pyuan7 = $ysum7 / $ycount7;
                }else{
                    if(empty($detail7)){
                        // 计算entry表中的数据
                        foreach($entry7 as $key31 => $value31){
                            $entry71[] = $value31['score'];
                        }
                        $cha7 = array_sum($entry71);
                        $ycount7 = count($score0);
                        $ysum7 = $ycount7 * 90 + $cha7;
                        $pyuan7 = round($ysum7 / $ycount7,2);
                    }elseif(empty($entry7)){
                        // 计算detail表中的数据
                        foreach($detail7 as $key32 => $value32){
                            $detail71[] = $value32['score'];
                        }
                        $cha7 = array_sum($detail71);
                        $ycount7 = count($score0);
                        $ysum7 = $ycount7 * 90 + $cha7;
                        $pyuan7 = round($ysum7 / $ycount7,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail7 as $key33 => $value33){
                            $detail71[] = $value33['score'];
                        }
                        foreach($entry7 as $key33 => $value33){
                            $entry71[] = $value33['score'];
                        }
                        $chaz711 = array_sum($detail71);
                        $chaz712 = array_sum($entry71);
                        $cha7 = $chaz711 + $chaz712;
                        $ycount7 = count($score0);
                        $ysum7 = $ycount7 * 90 + $cha7;
                        $pyuan7 = round($ysum7 / $ycount7,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where72['ktime'] = $ktime;
                $where72['mtime'] = array('in',$ktime15);
                $where72['score_id'] = array('in',$xinz_id);
                $where73['ktime'] = $ktime;
                $where73['mtime'] = array('in',$ktime14);
                $where73['score_id'] = array('in',$xinz_id);
                $detail71 = M('detail')->where($where72)->select();
                $entry71 = M('entry')->where($where73)->select();
                if(empty($detail71) && empty($entry71)){
                    // 默认值
                    $xcount7 = count($score1);
                    $xsum7 = $xcount7 * 90;
                    $pxinz7 = $xsum7 / $xcount7;
                }else{
                    if(empty($detail71)){
                        // 计算entry表中的数据
                        foreach($entry71 as $key41 => $value41){
                            $entry72[] = $value41['score'];
                        }
                        $cha7 = array_sum($entry72);
                        $xcount7 = count($score1);
                        $xsum7 = $xcount7 * 90 + $cha7;
                        $pxinz7 = round($xsum7 / $xcount7,2);
                    }elseif(empty($entry71)){
                        // 计算detail表中的数据
                        foreach($detail71 as $key42 => $value42){
                            $detail72[] = $value42['score'];
                        }
                        $cha7 = array_sum($detail72);
                        $xcount7 = count($score1);
                        $xsum7 = $xcount7 * 90 + $cha7;
                        $pxinz7 = round($xsum7 / $xcount7,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail71 as $key43 => $value43){
                            $detail72[] = $value43['score'];
                        }
                        foreach($entry71 as $key43 => $value43){
                            $entry72[] = $value43['score'];
                        }
                        $chaz711 = array_sum($detail72);
                        $chaz712 = array_sum($entry72);
                        $cha7 = $chaz711 + $chaz712;
                        $xcount7 = count($score1);
                        $xsum7 = $xcount7 * 90 + $cha7;
                        $pxinz7 = round($xsum7 / $xcount7,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where74['ktime'] = $ktime;
                $where74['mtime'] = array('in',$ktime15);
                $where74['score_id'] = array('in',$fuz_id);
                $where75['ktime'] = $ktime;
                $where75['mtime'] = array('in',$ktime14);
                $where75['score_id'] = array('in',$fuz_id);
                $detail72 = M('detail')->where($where74)->select();
                $entry72 = M('entry')->where($where75)->select();
                if(empty($detail72) && empty($entry72)){
                    // 默认值
                    $fcount7 = count($score2);
                    $fsum7 = $fcount7 * 90;
                    $pfuz7 = $fsum7 / $fcount7;
                }else{
                    if(empty($detail72)){
                        // 计算entry表中的数据
                        foreach($entry72 as $key51 => $value51){
                            $entry73[] = $value51['score'];
                        }
                        $cha7 = array_sum($entry73);
                        $fcount7 = count($score2);
                        $fsum7 = $fcount7 * 90 + $cha7;
                        $pfuz7 = round($fsum7 / $fcount7,2);
                    }elseif(empty($entry72)){
                        // 计算detail表中的数据
                        foreach($detail72 as $key52 => $value52){
                            $detail73[] = $value52['score'];
                        }
                        $cha7 = array_sum($detail73);
                        $fcount7 = count($score2);
                        $fsum7 = $fcount7 * 90 + $cha7;
                        $pfuz7 = round($fsum7 / $fcount7,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail72 as $key53 => $value53){
                            $detail73[] = $value53['score'];
                        }
                        foreach($entry72 as $key53 => $value53){
                            $entry73[] = $value53['score'];
                        }
                        $chaz721 = array_sum($detail73);
                        $chaz722 = array_sum($entry73);
                        $cha7 = $chaz721 + $chaz722;
                        $fcount7 = count($score2);
                        $fsum7 = $fcount7 * 90 + $cha7;
                        $pfuz7 = round($fsum7 / $fcount7,2);
                    }
                }
                // 七月 结束
                $yuan['6'] = $pyuan7;
                $xinz['6'] = $pxinz7;
                $fuz['6'] = $pfuz7;

                // 八月 开始
                for($i = 1;$i <= 8;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime16[] = $ktime1 . '-0' . $v;
                    $ktime17[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where80['ktime'] = $ktime;
                $where80['mtime'] = array('in',$ktime17);
                $where80['score_id'] = array('in',$yuan_id);
                $where81['ktime'] = $ktime;
                $where81['mtime'] = array('in',$ktime16);
                $where81['score_id'] = array('in',$yuan_id);
                $detail8 = M('detail')->where($where80)->select();
                $entry8 = M('entry')->where($where81)->select();
                if(empty($detail8) && empty($entry8)){
                    // 默认值
                    $ycount8 = count($score0);
                    $ysum8 = $ycount8 * 90;
                    $pyuan8 = $ysum8 / $ycount8;
                }else{
                    if(empty($detail8)){
                        // 计算entry表中的数据
                        foreach($entry8 as $key31 => $value31){
                            $entry81[] = $value31['score'];
                        }
                        $cha8 = array_sum($entry81);
                        $ycount8 = count($score0);
                        $ysum8 = $ycount8 * 90 + $cha8;
                        $pyuan8 = round($ysum8 / $ycount8,2);
                    }elseif(empty($entry8)){
                        // 计算detail表中的数据
                        foreach($detail8 as $key32 => $value32){
                            $detail81[] = $value32['score'];
                        }
                        $cha8 = array_sum($detail81);
                        $ycount8 = count($score0);
                        $ysum8 = $ycount8 * 90 + $cha8;
                        $pyuan8 = round($ysum8 / $ycount8,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail8 as $key33 => $value33){
                            $detail81[] = $value33['score'];
                        }
                        foreach($entry8 as $key33 => $value33){
                            $entry81[] = $value33['score'];
                        }
                        $chaz811 = array_sum($detail81);
                        $chaz812 = array_sum($entry81);
                        $cha8 = $chaz811 + $chaz812;
                        $ycount8 = count($score0);
                        $ysum8 = $ycount8 * 90 + $cha8;
                        $pyuan8 = round($ysum8 / $ycount8,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where82['ktime'] = $ktime;
                $where82['mtime'] = array('in',$ktime17);
                $where82['score_id'] = array('in',$xinz_id);
                $where83['ktime'] = $ktime;
                $where83['mtime'] = array('in',$ktime16);
                $where83['score_id'] = array('in',$xinz_id);
                $detail81 = M('detail')->where($where82)->select();
                $entry81 = M('entry')->where($where83)->select();
                if(empty($detail81) && empty($entry81)){
                    // 默认值
                    $xcount8 = count($score1);
                    $xsum8 = $xcount8 * 90;
                    $pxinz8 = $xsum8 / $xcount8;
                }else{
                    if(empty($detail81)){
                        // 计算entry表中的数据
                        foreach($entry81 as $key41 => $value41){
                            $entry82[] = $value41['score'];
                        }
                        $cha8 = array_sum($entry82);
                        $xcount8 = count($score1);
                        $xsum8 = $xcount8 * 90 + $cha8;
                        $pxinz8 = round($xsum8 / $xcount8,2);
                    }elseif(empty($entry81)){
                        // 计算detail表中的数据
                        foreach($detail81 as $key42 => $value42){
                            $detail82[] = $value42['score'];
                        }
                        $cha8 = array_sum($detail82);
                        $xcount8 = count($score1);
                        $xsum8 = $xcount8 * 90 + $cha8;
                        $pxinz8 = round($xsum8 / $xcount8,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail81 as $key43 => $value43){
                            $detail82[] = $value43['score'];
                        }
                        foreach($entry81 as $key43 => $value43){
                            $entry82[] = $value43['score'];
                        }
                        $chaz811 = array_sum($detail82);
                        $chaz812 = array_sum($entry82);
                        $cha8 = $chaz811 + $chaz812;
                        $xcount8 = count($score1);
                        $xsum8 = $xcount8 * 90 + $cha8;
                        $pxinz8 = round($xsum8 / $xcount8,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where84['ktime'] = $ktime;
                $where84['mtime'] = array('in',$ktime17);
                $where84['score_id'] = array('in',$fuz_id);
                $where85['ktime'] = $ktime;
                $where85['mtime'] = array('in',$ktime16);
                $where85['score_id'] = array('in',$fuz_id);
                $detail82 = M('detail')->where($where84)->select();
                $entry82 = M('entry')->where($where85)->select();
                if(empty($detail82) && empty($entry82)){
                    // 默认值
                    $fcount8 = count($score2);
                    $fsum8 = $fcount8 * 90;
                    $pfuz8 = $fsum8 / $fcount8;
                }else{
                    if(empty($detail82)){
                        // 计算entry表中的数据
                        foreach($entry82 as $key51 => $value51){
                            $entry83[] = $value51['score'];
                        }
                        $cha8 = array_sum($entry83);
                        $fcount8 = count($score2);
                        $fsum8 = $fcount8 * 90 + $cha8;
                        $pfuz8 = round($fsum8 / $fcount8,2);
                    }elseif(empty($entry82)){
                        // 计算detail表中的数据
                        foreach($detail82 as $key52 => $value52){
                            $detail83[] = $value52['score'];
                        }
                        $cha8 = array_sum($detail83);
                        $fcount8 = count($score2);
                        $fsum8 = $fcount8 * 90 + $cha8;
                        $pfuz8 = round($fsum8 / $fcount8,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail82 as $key53 => $value53){
                            $detail83[] = $value53['score'];
                        }
                        foreach($entry82 as $key53 => $value53){
                            $entry83[] = $value53['score'];
                        }
                        $chaz821 = array_sum($detail83);
                        $chaz822 = array_sum($entry83);
                        $cha8 = $chaz821 + $chaz822;
                        $fcount8 = count($score2);
                        $fsum8 = $fcount8 * 90 + $cha8;
                        $pfuz8 = round($fsum8 / $fcount8,2);
                    }
                }
                // 八月 结束
                $yuan['7'] = $pyuan8;
                $xinz['7'] = $pxinz8;
                $fuz['7'] = $pfuz8;

                // 九月 开始
                for($i = 1;$i <= 9;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime18[] = $ktime1 . '-0' . $v;
                    $ktime19[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where90['ktime'] = $ktime;
                $where90['mtime'] = array('in',$ktime19);
                $where90['score_id'] = array('in',$yuan_id);
                $where91['ktime'] = $ktime;
                $where91['mtime'] = array('in',$ktime18);
                $where91['score_id'] = array('in',$yuan_id);
                $detail9 = M('detail')->where($where90)->select();
                $entry9 = M('entry')->where($where91)->select();
                if(empty($detail9) && empty($entry9)){
                    // 默认值
                    $ycount9 = count($score0);
                    $ysum9 = $ycount9 * 90;
                    $pyuan9 = $ysum9 / $ycount9;
                }else{
                    if(empty($detail9)){
                        // 计算entry表中的数据
                        foreach($entry9 as $key31 => $value31){
                            $entry91[] = $value31['score'];
                        }
                        $cha9 = array_sum($entry91);
                        $ycount9 = count($score0);
                        $ysum9 = $ycount9 * 90 + $cha9;
                        $pyuan9 = round($ysum9 / $ycount9,2);
                    }elseif(empty($entry9)){
                        // 计算detail表中的数据
                        foreach($detail9 as $key32 => $value32){
                            $detail91[] = $value32['score'];
                        }
                        $cha9 = array_sum($detail91);
                        $ycount9 = count($score0);
                        $ysum9 = $ycount9 * 90 + $cha9;
                        $pyuan9 = round($ysum9 / $ycount9,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail9 as $key33 => $value33){
                            $detail91[] = $value33['score'];
                        }
                        foreach($entry9 as $key33 => $value33){
                            $entry91[] = $value33['score'];
                        }
                        $chaz911 = array_sum($detail91);
                        $chaz912 = array_sum($entry91);
                        $cha9 = $chaz911 + $chaz912;
                        $ycount9 = count($score0);
                        $ysum9 = $ycount9 * 90 + $cha9;
                        $pyuan9 = round($ysum9 / $ycount9,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where92['ktime'] = $ktime;
                $where92['mtime'] = array('in',$ktime19);
                $where92['score_id'] = array('in',$xinz_id);
                $where93['ktime'] = $ktime;
                $where93['mtime'] = array('in',$ktime18);
                $where93['score_id'] = array('in',$xinz_id);
                $detail91 = M('detail')->where($where92)->select();
                $entry91 = M('entry')->where($where93)->select();
                if(empty($detail91) && empty($entry91)){
                    // 默认值
                    $xcount9 = count($score1);
                    $xsum9 = $xcount9 * 90;
                    $pxinz9 = $xsum9 / $xcount9;
                }else{
                    if(empty($detail91)){
                        // 计算entry表中的数据
                        foreach($entry91 as $key41 => $value41){
                            $entry92[] = $value41['score'];
                        }
                        $cha9 = array_sum($entry92);
                        $xcount9 = count($score1);
                        $xsum9 = $xcount9 * 90 + $cha9;
                        $pxinz9 = round($xsum9 / $xcount9,2);
                    }elseif(empty($entry91)){
                        // 计算detail表中的数据
                        foreach($detail91 as $key42 => $value42){
                            $detail92[] = $value42['score'];
                        }
                        $cha9 = array_sum($detail92);
                        $xcount9 = count($score1);
                        $xsum9 = $xcount9 * 90 + $cha9;
                        $pxinz9 = round($xsum9 / $xcount9,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail91 as $key43 => $value43){
                            $detail92[] = $value43['score'];
                        }
                        foreach($entry91 as $key43 => $value43){
                            $entry92[] = $value43['score'];
                        }
                        $chaz911 = array_sum($detail92);
                        $chaz912 = array_sum($entry92);
                        $cha9 = $chaz911 + $chaz912;
                        $xcount9 = count($score1);
                        $xsum9 = $xcount9 * 90 + $cha9;
                        $pxinz9 = round($xsum9 / $xcount9,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where94['ktime'] = $ktime;
                $where94['mtime'] = array('in',$ktime19);
                $where94['score_id'] = array('in',$fuz_id);
                $where95['ktime'] = $ktime;
                $where95['mtime'] = array('in',$ktime18);
                $where95['score_id'] = array('in',$fuz_id);
                $detail92 = M('detail')->where($where94)->select();
                $entry92 = M('entry')->where($where95)->select();
                if(empty($detail92) && empty($entry92)){
                    // 默认值
                    $fcount9 = count($score2);
                    $fsum9 = $fcount9 * 90;
                    $pfuz9 = $fsum9 / $fcount9;
                }else{
                    if(empty($detail92)){
                        // 计算entry表中的数据
                        foreach($entry92 as $key51 => $value51){
                            $entry93[] = $value51['score'];
                        }
                        $cha9 = array_sum($entry93);
                        $fcount9 = count($score2);
                        $fsum9 = $fcount9 * 90 + $cha9;
                        $pfuz9 = round($fsum9 / $fcount9,2);
                    }elseif(empty($entry92)){
                        // 计算detail表中的数据
                        foreach($detail92 as $key52 => $value52){
                            $detail93[] = $value52['score'];
                        }
                        $cha9 = array_sum($detail93);
                        $fcount9 = count($score2);
                        $fsum9 = $fcount9 * 90 + $cha9;
                        $pfuz9 = round($fsum9 / $fcount9,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail92 as $key53 => $value53){
                            $detail93[] = $value53['score'];
                        }
                        foreach($entry92 as $key53 => $value53){
                            $entry93[] = $value53['score'];
                        }
                        $chaz921 = array_sum($detail93);
                        $chaz922 = array_sum($entry93);
                        $cha9 = $chaz921 + $chaz922;
                        $fcount9 = count($score2);
                        $fsum9 = $fcount9 * 90 + $cha9;
                        $pfuz9 = round($fsum9 / $fcount9,2);
                    }
                }
                // 九月 结束
                $yuan['8'] = $pyuan9;
                $xinz['8'] = $pxinz9;
                $fuz['8'] = $pfuz9;

                // 十月 开始
                for($i = 1;$i <= 10;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime20[] = $ktime1 . '-' . $v;
                    $ktime21[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where100['ktime'] = $ktime;
                $where100['mtime'] = array('in',$ktime21);
                $where100['score_id'] = array('in',$yuan_id);
                $where101['ktime'] = $ktime;
                $where101['mtime'] = array('in',$ktime20);
                $where101['score_id'] = array('in',$yuan_id);
                $detail10 = M('detail')->where($where100)->select();
                $entry10 = M('entry')->where($where101)->select();
                if(empty($detail10) && empty($entry10)){
                    // 默认值
                    $ycount10 = count($score0);
                    $ysum10 = $ycount10 * 90;
                    $pyuan10 = $ysum10 / $ycount10;
                }else{
                    if(empty($detail10)){
                        // 计算entry表中的数据
                        foreach($entry10 as $key31 => $value31){
                            $entry101[] = $value31['score'];
                        }
                        $cha10 = array_sum($entry101);
                        $ycount10 = count($score0);
                        $ysum10 = $ycount10 * 90 + $cha10;
                        $pyuan10 = round($ysum10 / $ycount10,2);
                    }elseif(empty($entry10)){
                        // 计算detail表中的数据
                        foreach($detail10 as $key32 => $value32){
                            $detail101[] = $value32['score'];
                        }
                        $cha10 = array_sum($detail101);
                        $ycount10 = count($score0);
                        $ysum10 = $ycount10 * 90 + $cha10;
                        $pyuan10 = round($ysum10 / $ycount10,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail10 as $key33 => $value33){
                            $detail101[] = $value33['score'];
                        }
                        foreach($entry10 as $key33 => $value33){
                            $entry101[] = $value33['score'];
                        }
                        $chaz1011 = array_sum($detail101);
                        $chaz1012 = array_sum($entry101);
                        $cha10 = $chaz1011 + $chaz1012;
                        $ycount10 = count($score0);
                        $ysum10 = $ycount10 * 90 + $cha10;
                        $pyuan10 = round($ysum10 / $ycount10,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where102['ktime'] = $ktime;
                $where102['mtime'] = array('in',$ktime21);
                $where102['score_id'] = array('in',$xinz_id);
                $where103['ktime'] = $ktime;
                $where103['mtime'] = array('in',$ktime20);
                $where103['score_id'] = array('in',$xinz_id);
                $detail101 = M('detail')->where($where102)->select();
                $entry101 = M('entry')->where($where103)->select();
                if(empty($detail101) && empty($entry101)){
                    // 默认值
                    $xcount10 = count($score1);
                    $xsum10 = $xcount10 * 90;
                    $pxinz10 = $xsum10 / $xcount10;
                }else{
                    if(empty($detail101)){
                        // 计算entry表中的数据
                        foreach($entry101 as $key41 => $value41){
                            $entry102[] = $value41['score'];
                        }
                        $cha10 = array_sum($entry102);
                        $xcount10 = count($score1);
                        $xsum10 = $xcount10 * 90 + $cha10;
                        $pxinz10 = round($xsum10 / $xcount10,2);
                    }elseif(empty($entry101)){
                        // 计算detail表中的数据
                        foreach($detail101 as $key42 => $value42){
                            $detail102[] = $value42['score'];
                        }
                        $cha10 = array_sum($detail102);
                        $xcount10 = count($score1);
                        $xsum10 = $xcount10 * 90 + $cha10;
                        $pxinz10 = round($xsum10 / $xcount10,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail101 as $key43 => $value43){
                            $detail102[] = $value43['score'];
                        }
                        foreach($entry31 as $key43 => $value43){
                            $entry102[] = $value43['score'];
                        }
                        $chaz1011 = array_sum($detail102);
                        $chaz1012 = array_sum($entry102);
                        $cha10 = $chaz1011 + $chaz1012;
                        $xcount10 = count($score1);
                        $xsum10 = $xcount10 * 90 + $cha10;
                        $pxinz10 = round($xsum10 / $xcount10,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where104['ktime'] = $ktime;
                $where104['mtime'] = array('in',$ktime21);
                $where104['score_id'] = array('in',$fuz_id);
                $where105['ktime'] = $ktime;
                $where105['mtime'] = array('in',$ktime20);
                $where105['score_id'] = array('in',$fuz_id);
                $detail102 = M('detail')->where($where104)->select();
                $entry102 = M('entry')->where($where105)->select();
                if(empty($detail102) && empty($entry102)){
                    // 默认值
                    $fcount10 = count($score2);
                    $fsum10 = $fcount10 * 90;
                    $pfuz10 = $fsum10 / $fcount10;
                }else{
                    if(empty($detail102)){
                        // 计算entry表中的数据
                        foreach($entry102 as $key51 => $value51){
                            $entry103[] = $value51['score'];
                        }
                        $cha10 = array_sum($entry103);
                        $fcount10 = count($score2);
                        $fsum10 = $fcount10 * 90 + $cha10;
                        $pfuz10 = round($fsum10 / $fcount10,2);
                    }elseif(empty($entry102)){
                        // 计算detail表中的数据
                        foreach($detail102 as $key52 => $value52){
                            $detail103[] = $value52['score'];
                        }
                        $cha10 = array_sum($detail103);
                        $fcount10 = count($score2);
                        $fsum10 = $fcount10 * 90 + $cha10;
                        $pfuz10 = round($fsum10 / $fcount10,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail102 as $key53 => $value53){
                            $detail103[] = $value53['score'];
                        }
                        foreach($entry102 as $key53 => $value53){
                            $entry103[] = $value53['score'];
                        }
                        $chaz1021 = array_sum($detail103);
                        $chaz1022 = array_sum($entry103);
                        $cha10 = $chaz1021 + $chaz1022;
                        $fcount10 = count($score2);
                        $fsum10 = $fcount10 * 90 + $cha10;
                        $pfuz10 = round($fsum10 / $fcount10,2);
                    }
                }
                // 十月 结束
                $yuan['9'] = $pyuan10;
                $xinz['9'] = $pxinz10;
                $fuz['9'] = $pfuz10;

                // 十一月 开始
                for($i = 1;$i <= 11;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime22[] = $ktime1 . '-0' . $v;
                    $ktime23[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where110['ktime'] = $ktime;
                $where110['mtime'] = array('in',$ktime23);
                $where110['score_id'] = array('in',$yuan_id);
                $where111['ktime'] = $ktime;
                $where111['mtime'] = array('in',$ktime22);
                $where111['score_id'] = array('in',$yuan_id);
                $detail11 = M('detail')->where($where110)->select();
                $entry11 = M('entry')->where($where111)->select();
                if(empty($detail11) && empty($entry11)){
                    // 默认值
                    $ycount11 = count($score0);
                    $ysum11 = $ycount11 * 90;
                    $pyuan11 = $ysum11 / $ycount11;
                }else{
                    if(empty($detail11)){
                        // 计算entry表中的数据
                        foreach($entry11 as $key31 => $value31){
                            $entry111[] = $value31['score'];
                        }
                        $cha11 = array_sum($entry111);
                        $ycount11 = count($score0);
                        $ysum11 = $ycount11 * 90 + $cha11;
                        $pyuan11 = round($ysum11 / $ycount11,2);
                    }elseif(empty($entry11)){
                        // 计算detail表中的数据
                        foreach($detail11 as $key32 => $value32){
                            $detail111[] = $value32['score'];
                        }
                        $cha11 = array_sum($detail111);
                        $ycount11 = count($score0);
                        $ysum11 = $ycount11 * 90 + $cha11;
                        $pyuan11 = round($ysum11 / $ycount11,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail11 as $key33 => $value33){
                            $detail111[] = $value33['score'];
                        }
                        foreach($entry11 as $key33 => $value33){
                            $entry111[] = $value33['score'];
                        }
                        $chaz1111 = array_sum($detail111);
                        $chaz1112 = array_sum($entry111);
                        $cha11 = $chaz1111 + $chaz1112;
                        $ycount11 = count($score0);
                        $ysum11 = $ycount11 * 90 + $cha11;
                        $pyuan11 = round($ysum11 / $ycount11,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where112['ktime'] = $ktime;
                $where112['mtime'] = array('in',$ktime23);
                $where112['score_id'] = array('in',$xinz_id);
                $where113['ktime'] = $ktime;
                $where113['mtime'] = array('in',$ktime22);
                $where113['score_id'] = array('in',$xinz_id);
                $detail111 = M('detail')->where($where112)->select();
                $entry111 = M('entry')->where($where113)->select();
                if(empty($detail111) && empty($entry111)){
                    // 默认值
                    $xcount11 = count($score1);
                    $xsum11 = $xcount11 * 90;
                    $pxinz11 = $xsum11 / $xcount11;
                }else{
                    if(empty($detail111)){
                        // 计算entry表中的数据
                        foreach($entry111 as $key41 => $value41){
                            $entry112[] = $value41['score'];
                        }
                        $cha11 = array_sum($entry112);
                        $xcount11 = count($score1);
                        $xsum11 = $xcount11 * 90 + $cha11;
                        $pxinz11 = round($xsum11 / $xcount11,2);
                    }elseif(empty($entry111)){
                        // 计算detail表中的数据
                        foreach($detail111 as $key42 => $value42){
                            $detail112[] = $value42['score'];
                        }
                        $cha11 = array_sum($detail112);
                        $xcount11 = count($score1);
                        $xsum11 = $xcount11 * 90 + $cha11;
                        $pxinz11 = round($xsum11 / $xcount11,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail111 as $key43 => $value43){
                            $detail112[] = $value43['score'];
                        }
                        foreach($entry111 as $key43 => $value43){
                            $entry112[] = $value43['score'];
                        }
                        $chaz1111 = array_sum($detail112);
                        $chaz1112 = array_sum($entry112);
                        $cha11 = $chaz1111 + $chaz1112;
                        $xcount11 = count($score1);
                        $xsum11 = $xcount11 * 90 + $cha11;
                        $pxinz11 = round($xsum11 / $xcount11,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where114['ktime'] = $ktime;
                $where114['mtime'] = array('in',$ktime23);
                $where114['score_id'] = array('in',$fuz_id);
                $where115['ktime'] = $ktime;
                $where115['mtime'] = array('in',$ktime22);
                $where115['score_id'] = array('in',$fuz_id);
                $detail112 = M('detail')->where($where114)->select();
                $entry112 = M('entry')->where($where115)->select();
                if(empty($detail112) && empty($entry112)){
                    // 默认值
                    $fcount11 = count($score2);
                    $fsum11 = $fcount11 * 90;
                    $pfuz11 = $fsum11 / $fcount11;
                }else{
                    if(empty($detail112)){
                        // 计算entry表中的数据
                        foreach($entry112 as $key51 => $value51){
                            $entry113[] = $value51['score'];
                        }
                        $cha11 = array_sum($entry113);
                        $fcount11 = count($score2);
                        $fsum11 = $fcount11 * 90 + $cha11;
                        $pfuz11 = round($fsum11 / $fcount11,2);
                    }elseif(empty($entry112)){
                        // 计算detail表中的数据
                        foreach($detail112 as $key52 => $value52){
                            $detail113[] = $value52['score'];
                        }
                        $cha11 = array_sum($detail113);
                        $fcount11 = count($score2);
                        $fsum11 = $fcount11 * 90 + $cha11;
                        $pfuz11 = round($fsum11 / $fcount11,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail112 as $key53 => $value53){
                            $detail113[] = $value53['score'];
                        }
                        foreach($entry112 as $key53 => $value53){
                            $entry113[] = $value53['score'];
                        }
                        $chaz1121 = array_sum($detail113);
                        $chaz1122 = array_sum($entry113);
                        $cha11 = $chaz1121 + $chaz1122;
                        $fcount11 = count($score2);
                        $fsum11 = $fcount11 * 90 + $cha11;
                        $pfuz11 = round($fsum11 / $fcount11,2);
                    }
                }
                // 十一月 结束
                $yuan['10'] = $pyuan11;
                $xinz['10'] = $pxinz11;
                $fuz['10'] = $pfuz11;

                // 十二月 开始
                for($i = 1;$i <= 12;$i++){
                    $a[] = $i;
                }
                $a = array_unique($a);
                foreach($a as $k => $v){
                    $ktime24[] = $ktime1 . '-0' . $v;
                    $ktime25[] = strtotime($ktime1 . '-' . $v);
                }
                // 员额法官
                foreach($score0 as $key3 => $value3){
                    $yuan_id[] = $value3['id'];
                }
                $where120['ktime'] = $ktime;
                $where120['mtime'] = array('in',$ktime25);
                $where120['score_id'] = array('in',$yuan_id);
                $where121['ktime'] = $ktime;
                $where121['mtime'] = array('in',$ktime24);
                $where121['score_id'] = array('in',$yuan_id);
                $detail12 = M('detail')->where($where120)->select();
                $entry12 = M('entry')->where($where121)->select();
                if(empty($detail12) && empty($entry12)){
                    // 默认值
                    $ycount12 = count($score0);
                    $ysum12 = $ycount12 * 90;
                    $pyuan12 = $ysum12 / $ycount12;
                }else{
                    if(empty($detail12)){
                        // 计算entry表中的数据
                        foreach($entry12 as $key31 => $value31){
                            $entry121[] = $value31['score'];
                        }
                        $cha12 = array_sum($entry121);
                        $ycount12 = count($score0);
                        $ysum12 = $ycount12 * 90 + $cha12;
                        $pyuan12 = round($ysum12 / $ycount12,2);
                    }elseif(empty($entry12)){
                        // 计算detail表中的数据
                        foreach($detail12 as $key32 => $value32){
                            $detail121[] = $value32['score'];
                        }
                        $cha12 = array_sum($detail121);
                        $ycount12 = count($score0);
                        $ysum12 = $ycount12 * 90 + $cha12;
                        $pyuan12 = round($ysum12 / $ycount12,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail12 as $key33 => $value33){
                            $detail121[] = $value33['score'];
                        }
                        foreach($entry12 as $key33 => $value33){
                            $entry121[] = $value33['score'];
                        }
                        $chaz1211 = array_sum($detail121);
                        $chaz1212 = array_sum($entry121);
                        $cha12 = $chaz1211 + $chaz1212;
                        $ycount12 = count($score0);
                        $ysum12 = $ycount12 * 90 + $cha12;
                        $pyuan12 = round($ysum12 / $ycount12,2);
                    }
                }
                // 司法行政人员
                foreach($score1 as $key4 => $value4){
                    $xinz_id[] = $value4['id'];
                }
                $where122['ktime'] = $ktime;
                $where122['mtime'] = array('in',$ktime25);
                $where122['score_id'] = array('in',$xinz_id);
                $where123['ktime'] = $ktime;
                $where123['mtime'] = array('in',$ktime24);
                $where123['score_id'] = array('in',$xinz_id);
                $detail121 = M('detail')->where($where122)->select();
                $entry121 = M('entry')->where($where123)->select();
                if(empty($detail121) && empty($entry121)){
                    // 默认值
                    $xcount12 = count($score1);
                    $xsum12 = $xcount12 * 90;
                    $pxinz12 = $xsum12 / $xcount12;
                }else{
                    if(empty($detail121)){
                        // 计算entry表中的数据
                        foreach($entry121 as $key41 => $value41){
                            $entry122[] = $value41['score'];
                        }
                        $cha12 = array_sum($entry122);
                        $xcount12 = count($score1);
                        $xsum12 = $xcount12 * 90 + $cha12;
                        $pxinz12 = round(12 / $xcount12,2);
                    }elseif(empty($entry121)){
                        // 计算detail表中的数据
                        foreach($detail121 as $key42 => $value42){
                            $detail122[] = $value42['score'];
                        }
                        $cha12 = array_sum($detail122);
                        $xcount12 = count($score1);
                        $xsum12 = $xcount12 * 90 + $cha12;
                        $pxinz12 = round($xsum12 / $xcount12,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail121 as $key43 => $value43){
                            $detail122[] = $value43['score'];
                        }
                        foreach($entry121 as $key43 => $value43){
                            $entry122[] = $value43['score'];
                        }
                        $chaz1211 = array_sum($detail122);
                        $chaz1212 = array_sum($entry122);
                        $cha12 = $chaz1211 + $chaz1212;
                        $xcount12 = count($score1);
                        $xsum12 = $xcount12 * 90 + $cha12;
                        $pxinz12 = round($xsum12 / $xcount12,2);
                    }
                }
                // 司法辅助人员
                foreach($score2 as $key5 => $value5){
                    $fuz_id[] = $value5['id'];
                }
                $where124['ktime'] = $ktime;
                $where124['mtime'] = array('in',$ktime25);
                $where124['score_id'] = array('in',$fuz_id);
                $where125['ktime'] = $ktime;
                $where125['mtime'] = array('in',$ktime24);
                $where125['score_id'] = array('in',$fuz_id);
                $detail122 = M('detail')->where($where124)->select();
                $entry122 = M('entry')->where($where125)->select();
                if(empty($detail122) && empty($entry122)){
                    // 默认值
                    $fcount12 = count($score2);
                    $fsum12 = $fcount12 * 90;
                    $pfuz12 = $fsum12 / $fcount12;
                }else{
                    if(empty($detail122)){
                        // 计算entry表中的数据
                        foreach($entry122 as $key51 => $value51){
                            $entry123[] = $value51['score'];
                        }
                        $cha12 = array_sum($entry123);
                        $fcount12 = count($score2);
                        $fsum12 = $fcount12 * 90 + $cha12;
                        $pfuz12 = round($fsum12 / $fcount12,2);
                    }elseif(empty($entry122)){
                        // 计算detail表中的数据
                        foreach($detail122 as $key52 => $value52){
                            $detail123[] = $value52['score'];
                        }
                        $cha12 = array_sum($detail123);
                        $fcount12 = count($score2);
                        $fsum12 = $fcount12 * 90 + $cha12;
                        $pfuz12 = round($fsum12 / $fcount12,2);
                    }else{
                        // 计算detail表和entry表中的数据和
                        foreach($detail122 as $key53 => $value53){
                            $detail123[] = $value53['score'];
                        }
                        foreach($entry122 as $key53 => $value53){
                            $entry123[] = $value53['score'];
                        }
                        $chaz1221 = array_sum($detail123);
                        $chaz1222 = array_sum($entry123);
                        $cha12 = $chaz1221 + $chaz1222;
                        $fcount12 = count($score2);
                        $fsum12 = $fcount12 * 90 + $cha12;
                        $pfuz12 = round($fsum12 / $fcount12,2);
                    }
                }
                // 十二月 结束
                $yuan['11'] = $pyuan12;
                $xinz['11'] = $pxinz12;
                $fuz['11'] = $pfuz12;
                $yuane = implode(',',$yuan);
                $xinz = implode(',',$xinz);
                $fuz = implode(',',$fuz);
            // 板块二 结束
            
            // 板块三 开始
                // 员额法官
                foreach($score0 as $k3 => $v3){
                    $worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
                    foreach($worker as $k4 => $v4){
                        $yuan1[$k3]['worker_name'] = $v4['worker_name'];
                    }
                    $yuan1[$k3]['sum'] = $v3['sum'];
                }
                // 排序
                $sums = array();
                foreach($yuan1 as $li){
                    $sums[] = $li['sum'];
                }
                array_multisort($sums,SORT_DESC,$yuan1);
                $yname1 = 0;
                $ysum1 = 0;
                $b = count($yuan1);
                for($i=0;$i<$b;$i++){
                    $yname1 .= $yuan1[$i]['worker_name'] . ',';
                    $ysum1 .= $yuan1[$i]['sum'] . ',';
                }
                $yname1 = substr($yname1,1);
                $ysum1 = substr($ysum1,1);
                $yname = rtrim($yname1,',');
                $ysum = rtrim($ysum1,',');
            // 板块三 结束
            
            // 板块四 开始
                // 部门 
                $team1 = M('team')->order('team_id asc')->select();
                foreach($team1 as $key => $value){
                    $team_name[] = $value['team_name'];
                    $worker[$key] = M('worker')->where('team_id='.$value['team_id'])->select();
                }
                $team = implode(',',$team_name); // 部门名称
                foreach($worker as $key1 => $value1){
                    foreach($value1 as $key2 => $value2){
                        $bum[$key1][] = $value2['worker_id']; // 每个部门所有人员id
                    }
                }
                foreach($score as $key3 => $value3){
                    $sworker[$key3] = $value3['worker_id']; // 最新考核表下考核人员
                }
                foreach($bum as $key4 => $value4){
                    $bum1[$key4] = array_intersect($sworker,$value4); // 每个部门考核人员
                    $bumcount[$key4] = count($value4); // 每个部门人数
                }
                // var_dump($bumcount);die;
                foreach($bum1 as $key5 => $value5){
                    if(empty($value5)){
                        $bumen1[] = $key5; // 考核人员为空的部门
                        foreach($team_name as $key6 => $value6){
                            foreach($bumen1 as $key7 => $value7){
                                if($key6 == $value7){
                                    $pbumen1[$key5]['team_name'] = $value6; // 考核人员为空的部门
                                    $pbumen1[$key5]['fen'] = 0; // 考核人员为空的部门平均分数
                                }
                            }
                        }
                    }else{
                        $bumen2[] = $key5; // 考核人员不为空的部门
                        $brenyuan[$key5] = $value5; // 考核部门不为空的部门人员id
                        foreach($brenyuan as $key8 => $value8){
                            foreach($value8 as $key9 => $value9){
                                foreach($score as $key10 => $value10){
                                    $kaohe[$key10]['worker_id'] = $value10['worker_id'];
                                    $kaohe[$key10]['score_id'] = $value10['id'];
                                    if($value9 == $value10['worker_id']){
                                        $kaohe[$key10]['team_id'] = $key8;
                                    }
                                }
                            }
                        }
                    }
                }
                // echo "<pre>";
                // var_dump($bumen2);
                // echo "</pre>";die;
                foreach($kaohe as $key11 => $value11){
                    $khscore_id[] = $value11['score_id'];
                    $tiao['score_id'] = array('in',$khscore_id);
                    $tiao['ktime'] = $ktime;
                }
                $detail4 = M('detail')->where($tiao)->select();
                $entry4 = M('entry')->where($tiao)->select();
                if(empty($detail4) && empty($entry)){
                    foreach($kaohe as $key12 => $value12){
                        $kaohe[$key12]['sum'] = 90;
                    }
                }elseif(empty($detail4)){
                    // 计算entry表中的数据
                    foreach($entry4 as $k4 => $v4){
                        $scor3[] = $v4['score_id'];
                    }
                    $scor4 = array_unique($scor3);
                    foreach($scor4 as $k5 => $v5){
                        $res2[$k5]['id'] = $v5;
                        $tj1['score_id'] = $v5;
                        // $tj1['mtime'] = array('in',$ctime2);
                        $tj1['ktime'] = $ktime;
                        $etry1[] = M('entry')->where($tj1)->select();
                    }
                    foreach($scor4 as $k5 => $v5){
                        foreach($etry1 as $k6 => $v6){
                            foreach($v6 as $k7 => $v7){
                                if($v5 == $v7['score_id']){
                                    $res2[$k5]['cha'] += $v7['score'];
                                }
                            }
                        }
                    }
                    foreach($kaohe as $k9 => $v9){
                        $kaohe[$k9]['sum'] = 90;
                        foreach($res2 as $k8 => $v8){
                            if($v8['id'] == $v9['score_id']){
                                $kaohe[$k9]['sum'] = 90 + $v8['cha'];
                            }
                        }
                    }
                }elseif(empty($entry4)){
                    // 计算detail表中的数据
                    foreach($detail4 as $k1 => $v1){
                        $scor1[] = $v1['score_id'];
                    }
                    $scor2 = array_unique($scor1);
                    foreach($scor2 as $k2 => $v2){
                        $res1[$k2]['id'] = $v2;
                        $tj['score_id'] = $v2;
                        // $tj['mtime'] = array('in',$ctime1);
                        $tj['ktime'] = $ktime;
                        $detil1[] = M('detail')->where($tj)->select();
                    }
                    foreach($scor2 as $k2 => $v2){
                        foreach($detil1 as $k8 => $v8){
                            foreach($v8 as $k9 => $v9){
                                if($v2 == $v9['score_id']){
                                    $res1[$k2]['cha'] += $v9['score'];
                                }
                            }
                        }
                    }
                    foreach($kaohe as $k9 => $v9){
                        $kaohe[$k9]['sum'] = 90;
                        foreach($res1 as $k7 => $v7){
                            if($v7['id'] == $v9['score_id']){
                                $kaohe[$k9]['sum'] = 90 + $v7['cha'];
                            }
                        }
                    }                               
                }else{
                    // 计算detail表和entry表中的数据和
                    foreach($detail4 as $k1 => $v1){
                        $scor1[] = $v1['score_id'];
                    }
                    $scor2 = array_unique($scor1);
                    // var_dump($scor2);die;
                    foreach($scor2 as $k2 => $v2){
                        $res1[$k2]['id'] = $v2;
                        $tj['score_id'] = $v2;
                        // $tj['mtime'] = array('in',$ctime1);
                        $tj['ktime'] = $ktime;
                        $detil1[] = M('detail')->where($tj)->select();
                    }
                    foreach($scor2 as $k2 => $v2){
                        foreach($detil1 as $k8 => $v8){
                            foreach($v8 as $k9 => $v9){
                                if($v2 == $v9['score_id']){
                                    $res1[$k2]['cha'] += $v9['score'];
                                }
                            }
                        }
                    }
                    // echo "<pre>";
                    // var_dump($res1);
                    // echo "</pre>";die;
                    foreach($entry4 as $k4 => $v4){
                        $scor3[] = $v4['score_id'];
                    }
                    $scor4 = array_unique($scor3);
                    // var_dump($score4);die;
                    foreach($scor4 as $k5 => $v5){
                        $res2[$k5]['id'] = $v5;
                        $tj1['score_id'] = $v5;
                        // $tj1['mtime'] = array('in',$ctime2);
                        $tj1['ktime'] = $ktime;
                        $etry1[] = M('entry')->where($tj1)->select();
                    }
                    foreach($scor4 as $k5 => $v5){
                        foreach($etry1 as $k6 => $v6){
                            foreach($v6 as $k7 => $v7){
                                if($v5 == $v7['score_id']){
                                    $res2[$k5]['cha'] += $v7['score'];
                                }
                            }
                        }
                    }
                    // echo "<pre>";
                    // var_dump($res2);
                    // echo "</pre>";die;
                    $lis = array_merge_recursive($res1,$res2);
                    foreach($lis as $key => $val){
                        $deen[] = $val['id'];
                    }
                    $deen1 = array_unique($deen);
                    foreach($lis as $key1 => $val1){
                        foreach($deen1 as $key2 => $val2){
                            if($val2 == $val1['id']){
                                $li3[$key2]['id'] = $val1['id'];
                                $li3[$key2]['cha'] += $val1['cha'];
                            }
                        }
                    }
                    // echo "<pre>";
                    // var_dump($li3);
                    // echo "</pre>";die;
                    foreach($kaohe as $key3 => $val3){
                        $kaohe[$key3]['sum'] = 90;
                        foreach($li3 as $key4 => $val4){
                            if($val4['id'] == $val3['score_id']){
                                $kaohe[$key3]['sum'] = 90 + $val4['cha'];
                            }
                        }
                    }
                }
                // echo "<pre>";
                // var_dump($kaohe);
                // echo "</pre>";die;
                foreach($bumen2 as $key12 => $value12){
                    foreach($kaohe as $key13 => $value13){
                        if($value12 == $value13['team_id']){
                            $pbumen2[$value12] += $value13['sum']; // 各部门总分数
                        }   
                    }
                    foreach($pbumen2 as $key14 => $value14){
                        foreach($team_name as $key16 => $value16){
                            if($key14 == $key16){
                                $pbumen3[$key14]['team_name'] = $value16;
                            }
                        }
                        foreach($bumcount as $key15 => $value15){
                            if($key14 == $key15){
                                $pbumen3[$key14]['fen'] = round($value14 / $value15,2);
                            }
                        }
                    }
                }
                $pbumen4 = $pbumen1 + $pbumen3;
                ksort($pbumen4);
                foreach($pbumen4 as $key17 => $value17){
                    $pb_name1[] = $value17['team_name'];
                    $pb_fen1[] = $value17['fen'];
                }
                $pb_name = implode(',',$pb_name1);
                $pb_fen = implode(',',$pb_fen1);
                $month = '年';
            // 板块四 结束 
            }
            $this->assign('notes',$notes);
            $this->assign('notes1',$notes);
            $this->assign('notes2',$notes);
            $this->assign('notes3',$notes);
            $this->assign('posts',$posts);
            $this->assign('list0',$list0); // 员额法官
            $this->assign('list1',$list1); // 司法行政人员
            $this->assign('list2',$list2); // 司法辅助人员
            $this->assign('list',$list); // 所有人
            $this->assign('yname',$yname); // 当前员额法官考核名单
            $this->assign('ysum',$ysum); // 当前员额法官考核成绩
            $this->assign('yuane',$yuane);
            $this->assign('xinz',$xinz);
            $this->assign('fuz',$fuz);
            $this->assign('team',$team); // 部门
            $this->assign('pb_name',$pb_name);
            $this->assign('pb_fen',$pb_fen);
            $this->assign('month',$month);
            $this->display();
        }else{
            $this->error('无考核人员，请添加！',U('worker/check_list'));
        }
    
    }
	/*
		按岗位查看ajax请求
	 */
	public function score_list1(){
		// var_dump($_POST);die;
		$id = $_POST['id']; // 考核记录表id
		$posts_id  = $_POST['posts_id']; // 岗位id
		$notes = M('notes')->where('id='.$id)->find();
		$pos = M('posts')->where('parent_id='.$posts_id)->select();
		foreach($pos as $k => $v){
			$cp[] = $v['posts_id'];
		}
		$time = $notes['ktime'];
		$map['test_time'] = $time;
		$map['posts_id'] = array('in',$cp);
		$list = M('score')->where($map)->select();
		// echo "<pre>";
		// var_dump($list);
		// echo "</pre>";die;
		$map1['posts'] = $posts_id;
		$map1['ktime'] = date("Y",$time);
		$class = M('class')->where($map1)->select();
		// var_dump($class);die;
		foreach($list as $key => $val){
			if($val['sum'] >= $class['0']['bottom'] && $val['sum'] < $class['0']['top']){
				$list[$key]['dang'] = '优秀';
			}elseif($val['sum'] >= $class['1']['bottom'] && $val['sum'] < $class['1']['top']){
				$list[$key]['dang'] = '良好';
			}elseif($val['sum'] >= $class['2']['bottom'] && $val['sum'] < $class['2']['top']){
				$list[$key]['dang'] = '一般';
			}elseif($val['sum'] >= $class['3']['bottom'] && $val['sum'] < $class['3']['top']){
				$list[$key]['dang'] = '差';
			}
		}
		// 排序
		$sums = array();
		foreach($list as $li){
			$sums[] = $li['sum'];
		}
		array_multisort($sums,SORT_DESC,$list);
		// echo "<pre>";
		// var_dump($list);
		// echo "</pre>";die;
		$count = count($list);
		$this->assign('notes_id',$id);
		$this->assign('pos',$posts_id);
		$this->assign('score',$list);
		$this->display('score_list1');

	}

	/*
		按月份查看ajax请求
	 */
	public function score_list2(){
		// var_dump($_POST);die;
		$id = $_POST['id']; // 考核表id
		$month = $_POST['month']; // 月份
		$posts_id = $_POST['posts_id']; // 岗位id
		$notes = M('notes')->where('id='.$id)->find();
		$year = date("Y",$notes['ktime']);
		$ppp = M('posts')->where('parent_id='.$posts_id)->select();
		foreach($ppp as $k1 => $v1){
			$ppo[] = $v1['posts_id'];
		}
		$mp1['posts_id'] = array('in',$ppo);
		$mp1['test_time'] = $notes['ktime'];
		$sc = M('score')->where($mp1)->select();
		foreach($sc as $k2 => $v2){
			$score_id[] = $v2['id'];
		}
		if($month == '1'){
			$ctime1 = strtotime($year .'-'. $month); // 要查看的年-月
			$ctime2 = $year . '-0' . $month;
			$map1['mtime'] = $ctime1;
			$map1['score_id'] = array('in',$score_id);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = $ctime2;
			$map2['score_id'] = array('in',$score_id);
			$map2['ktime'] = $notes['ktime'];
		}else{
			for($i = 1;$i <= $month;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year .'-'. $v);
				if($v == 10){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
				}elseif($v == 11){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
					$ctime2['10'] = $year . '-' . '11';
				}elseif($v == 12){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
					$ctime2['10'] = $year . '-' . '11';
					$ctime2['11'] = $year . '-' . '12';
				}else{
					$ctime2[] = $year . '-0' . $v;
				}
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$score_id);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$score_id);
			$map2['ktime'] = $notes['ktime'];
		}
		$detail = M('detail')->where($map1)->select();
		$entry = M('entry')->where($map2)->select();
		if(empty($detail) && empty($entry)){
			// 默认值
			foreach($sc as $key => $val){
				$sc[$key]['public'] = 10;
				$sc[$key]['part'] = 10;
				$sc[$key]['price'] = 0;
				$sc[$key]['check'] = 0;
				$sc[$key]['work'] = 70;
				$sc[$key]['sum'] = 90;
			}
			$map1['posts'] = $posts_id;
			$map1['ktime'] = $year;
			$class = M('class')->where($map1)->select();
			foreach($sc as $key9 => $val9){
				if($val9['sum'] >= $class['0']['bottom'] && $val9['sum'] < $class['0']['top']){
					$sc[$key9]['dang'] = '优秀';
				}elseif($val9['sum'] >= $class['1']['bottom'] && $val9['sum'] < $class['1']['top']){
					$sc[$key9]['dang'] = '良好';
				}elseif($val9['sum'] >= $class['2']['bottom'] && $val9['sum'] < $class['2']['top']){
					$sc[$key9]['dang'] = '一般';
				}elseif($val9['sum'] >= $class['3']['bottom'] && $val9['sum'] < $class['3']['top']){
					$sc[$key9]['dang'] = '差';
				}
			}
			// 排序
			$sums = array();
			foreach($sc as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$sc);
			$this->assign('notes_id',$id);
			$this->assign('pos',$posts_id);
			$this->assign('score',$sc);
			$this->display();
		}elseif(empty($detail)){
			// 计算entry表中的数据
			foreach($sc as $k => $v){
				$sc[$k]['public'] = 10;
				$sc[$k]['part'] = 10;
				$sc[$k]['price'] = 0;
				$sc[$k]['check'] = 0;
				$map4['mtime'] = array('in',$ctime2);
				$map4['score_id'] = $v['id'];
				$map4['ktime'] = $notes['ktime'];
				$entry1 = M('entry')->where($map4)->select();
				if(empty($entry1)){
					$sc[$k]['work'] = 70;
				}else{
					foreach($entry1 as $Key8 => $val8){
						$entry2[] = $val8['score'];
					}
					$work2 = array_sum($entry2);
					$sc[$k]['work'] = 70 + $work2;
				}
				$sc[$k]['sum'] = $sc[$k]['public'] + $sc[$k]['part'] + $sc[$k]['price'] + $sc[$k]['check'] + $sc[$k]['work'];
			}
			$map5['posts'] = $posts_id;
			$map5['ktime'] = $year;
			$class = M('class')->where($map5)->select();
			foreach($sc as $key9 => $val9){
				if($val9['sum'] >= $class['0']['bottom'] && $val9['sum'] < $class['0']['top']){
					$sc[$key9]['dang'] = '优秀';
				}elseif($val9['sum'] >= $class['1']['bottom'] && $val9['sum'] < $class['1']['top']){
					$sc[$key9]['dang'] = '良好';
				}elseif($val9['sum'] >= $class['2']['bottom'] && $val9['sum'] < $class['2']['top']){
					$sc[$key9]['dang'] = '一般';
				}elseif($val9['sum'] >= $class['3']['bottom'] && $val9['sum'] < $class['3']['top']){
					$sc[$key9]['dang'] = '差';
				}
			}
			// 排序
			$sums = array();
			foreach($sc as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$sc);
			// echo "<pre>";
			// var_dump($sc);
			// echo "</pre>";die;
			$this->assign('notes_id',$id);
			$this->assign('pos',$posts_id);
			$this->assign('score',$sc);
			$this->display();
		}elseif(empty($entry)){
			// 计算detail表中的数据
			foreach($detail as $key => $val){
				$p_id1[] = $val['p_id'];
			}
			$p_id = array_unique($p_id1);
			foreach($sc as $k => $v){
				foreach($p_id as $key1 => $val1){
					if($val1 == '7'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '7';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key3 => $val3){
								$pub[] = $val3['score'];
							}
							$public = array_sum($pub);
							$sc[$k]['public'] = 10 + $public;
						}else{
							$sc[$k]['public'] = 10;
						}
					}elseif($val1 == '8'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '8';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key4 => $val4){
								$par[] = $val4['score'];
							}
							$part = array_sum($par);
							$sc[$k]['part'] = 10 + $part;
						}else{
							$sc[$k]['part'] = 10;
						}
					}elseif($val1 == '9'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '9';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key5 => $val5){
								$pric[] = $val5['score'];
							}
							$price = array_sum($pric);
							$sc[$k]['price'] = 0 + $price;
						}else{
							$sc[$k]['price'] = 0;
						}
					}elseif($val1 == '10'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '10';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key6 => $val6){
								$cscore[] = $val6['score'];
							}
							$zscore = array_sum($cscore);
							$sc[$k]['check'] = 0 + $zscore;
						}else{
							$sc[$k]['check'] = 0;
						}
					}elseif($val1 == '11'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '11';
						$map3['ktime'] = $notes['ktime'];
						$detail1 = M('detail')->where($map3)->select();
						if(!empty($detail1)){
							$sc[$k]['work'] = 70;
						}else{
							foreach($detail1 as $key7 => $val7){
								$detail2[] = $val7['score'];
							}
							$work1 = array_sum($detail2);
							$sc[$k]['work'] = 70 + $work1;
						}
					}
				}
				$sc[$k]['sum'] = $sc[$k]['public'] + $sc[$k]['part'] + $sc[$k]['price'] + $sc[$k]['check'] + $sc[$k]['work'];
			}
			$map5['posts'] = $posts_id;
			$map5['ktime'] = $year;
			$class = M('class')->where($map5)->select();
			foreach($sc as $key9 => $val9){
				if($val9['sum'] >= $class['0']['bottom'] && $val9['sum'] < $class['0']['top']){
					$sc[$key9]['dang'] = '优秀';
				}elseif($val9['sum'] >= $class['1']['bottom'] && $val9['sum'] < $class['1']['top']){
					$sc[$key9]['dang'] = '良好';
				}elseif($val9['sum'] >= $class['2']['bottom'] && $val9['sum'] < $class['2']['top']){
					$sc[$key9]['dang'] = '一般';
				}elseif($val9['sum'] >= $class['3']['bottom'] && $val9['sum'] < $class['3']['top']){
					$sc[$key9]['dang'] = '差';
				}
			}
			// 排序
			$sums = array();
			foreach($sc as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$sc);
			// echo "<pre>";
			// var_dump($sc);
			// echo "</pre>";die;
			$this->assign('notes_id',$id);
			$this->assign('pos',$posts_id);
			$this->assign('score',$sc);
			$this->display();
		}else{
			// 计算detail表和entry表中的数据和
			foreach($detail as $key => $val){
				$p_id1[] = $val['p_id'];
			}
			$p_id = array_unique($p_id1);
			foreach($sc as $k => $v){
				foreach($p_id as $key1 => $val1){
					if($val1 == '7'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '7';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key3 => $val3){
								$pub[] = $val3['score'];
							}
							$public = array_sum($pub);
							$sc[$k]['public'] = 10 + $public;
						}else{
							$sc[$k]['public'] = 10;
						}
					}elseif($val1 == '8'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '8';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key4 => $val4){
								$par[] = $val4['score'];
							}
							$part = array_sum($par);
							$sc[$k]['part'] = 10 + $part;
						}else{
							$sc[$k]['part'] = 10;
						}
					}elseif($val1 == '9'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '9';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key5 => $val5){
								$pric[] = $val5['score'];
							}
							$price = array_sum($pric);
							$sc[$k]['price'] = 0 + $price;
						}else{
							$sc[$k]['price'] = 0;
						}
					}elseif($val1 == '10'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '10';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key6 => $val6){
								$cscore[] = $val6['score'];
							}
							$zscore = array_sum($cscore);
							$sc[$k]['check'] = 0 + $zscore;
						}else{
							$sc[$k]['check'] = 0;
						}
					}elseif($val1 == '11'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '11';
						$map3['ktime'] = $notes['ktime'];
						$map4['mtime'] = array('in',$ctime2);
						$map4['score_id'] = $v['id'];
						$map4['ktime'] = $notes['ktime'];
						$detail1 = M('detail')->where($map3)->select();
						$entry1 = M('entry')->where($map4)->select();
						if(empty($detail1) && empty($entry1)){
							$sc[$k]['work'] = 70;
						}elseif(empty($detail1)){
							foreach($entry1 as $Key8 => $val8){
								$entry2[] = $val8['score'];
							}
							$work2 = array_sum($entry2);
							$sc[$k]['work'] = 70 + $work2;
						}elseif(empty($entry1)){
							foreach($detail1 as $key7 => $val7){
								$detail2[] = $val7['score'];
							}
							$work1 = array_sum($detail2);
							$sc[$k]['work'] = 70 + $work1;
						}else{
							foreach($detail1 as $key7 => $val7){
								$detail2[] = $val7['score'];
							}
							$work1 = array_sum($detail2);
							foreach($entry1 as $Key8 => $val8){
								$entry2[] = $val8['score'];
							}
							$work2 = array_sum($entry2);
							$sc[$k]['work'] = 70 + $work1 + $work2;
						}
					}
				}
				$sc[$k]['sum'] = $sc[$k]['public'] + $sc[$k]['part'] + $sc[$k]['price'] + $sc[$k]['check'] + $sc[$k]['work'];
			}
			$map5['posts'] = $posts_id;
			$map5['ktime'] = $year;
			$class = M('class')->where($map5)->select();
			foreach($sc as $key9 => $val9){
				if($val9['sum'] >= $class['0']['bottom'] && $val9['sum'] < $class['0']['top']){
					$sc[$key9]['dang'] = '优秀';
				}elseif($val9['sum'] >= $class['1']['bottom'] && $val9['sum'] < $class['1']['top']){
					$sc[$key9]['dang'] = '良好';
				}elseif($val9['sum'] >= $class['2']['bottom'] && $val9['sum'] < $class['2']['top']){
					$sc[$key9]['dang'] = '一般';
				}elseif($val9['sum'] >= $class['3']['bottom'] && $val9['sum'] < $class['3']['top']){
					$sc[$key9]['dang'] = '差';
				}
			}
			// 排序
			$sums = array();
			foreach($sc as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$sc);
			// echo "<pre>";
			// var_dump($sc);
			// echo "</pre>";die;
			$this->assign('notes_id',$id);
			$this->assign('pos',$posts_id);
			$this->assign('score',$sc);
			$this->display();
		}
	}

	/*
		按季度查看ajax请求
	 */
	public function score_list3(){
		// var_dump($_POST);die;
		$id = $_POST['id']; // 考核表id
		// var_dump($id);die;
		$quarter = $_POST['quarter']; // 季度
		$posts_id = $_POST['posts_id']; // 岗位id
		$notes = M('notes')->where('id='.$id)->find();
		$year = date("Y",$notes['ktime']);
		$ppp = M('posts')->where('parent_id='.$posts_id)->select();
		foreach($ppp as $k1 => $v1){
			$ppo[] = $v1['posts_id'];
		}
		$mp1['posts_id'] = array('in',$ppo);
		$mp1['test_time'] = $notes['ktime'];
		$sc = M('score')->where($mp1)->select();
		foreach($sc as $k2 => $v2){
			$sc_id[] = $v2['id'];
		}
		if($quarter == '1'){
			for($i = 1;$i <= 3;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year .'-0'. $v);
				$ctime2[] = $year . '-0' . $v;
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$sc_id);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$sc_id);
			$map2['ktime'] = $notes['ktime'];
		}elseif($quarter == '2'){
			for($i = 1;$i <= 6;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year . '-0' . $v);
				$ctime2[] = $year . '-0' . $v;
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$sc_id);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$sc_id);
			$map2['ktime'] = $notes['ktime'];
		}elseif($quarter == '3'){
			for($i = 1;$i <= 9;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year . '-0' . $v);
				$ctime2[] = $year . '-0' . $v;
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$sc_id);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$sc_id);
			$map2['ktime'] = $notes['ktime'];
		}elseif($quarter == '4'){
			for($i = 1;$i <= 12;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year . '-' . $v);
				if($v == 10){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
				}elseif($v == 11){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
					$ctime2['10'] = $year . '-' . '11';
				}elseif($v == 12){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
					$ctime2['10'] = $year . '-' . '11';
					$ctime2['11'] = $year . '-' . '12';
				}else{
					$ctime2[] = $year . '-0' . $v;
				}
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$sc_id);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$sc_id);
			$map2['ktime'] = $notes['ktime'];
		}
		$detail = M('detail')->where($map1)->select();
		$entry = M('entry')->where($map2)->select();
		if(empty($detail) && empty($entry)){
			// 默认值
			foreach($sc as $key => $val){
				$sc[$key]['public'] = 10;
				$sc[$key]['part'] = 10;
				$sc[$key]['price'] = 0;
				$sc[$key]['check'] = 0;
				$sc[$key]['work'] = 70;
				$sc[$key]['sum'] = 90;
			}
			$map1['posts'] = $posts_id;
			$map1['ktime'] = $year;
			$class = M('class')->where($map1)->select();
			foreach($sc as $key9 => $val9){
				if($val9['sum'] >= $class['0']['bottom'] && $val9['sum'] < $class['0']['top']){
					$sc[$key9]['dang'] = '优秀';
				}elseif($val9['sum'] >= $class['1']['bottom'] && $val9['sum'] < $class['1']['top']){
					$sc[$key9]['dang'] = '良好';
				}elseif($val9['sum'] >= $class['2']['bottom'] && $val9['sum'] < $class['2']['top']){
					$sc[$key9]['dang'] = '一般';
				}elseif($val9['sum'] >= $class['3']['bottom'] && $val9['sum'] < $class['3']['top']){
					$sc[$key9]['dang'] = '差';
				}
			}
			// 排序
			$sums = array();
			foreach($sc as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$sc);
			// echo "<pre>";
			// var_dump($sc);
			// echo "</pre>";die;
			$this->assign('notes_id',$id);
			$this->assign('pos',$posts_id);
			$this->assign('score',$sc);
			$this->display();
		}elseif(empty($detail)){
			// 计算entry表中的数据
			foreach($sc as $k => $v){
				$sc[$k]['public'] = 10;
				$sc[$k]['part'] = 10;
				$sc[$k]['price'] = 0;
				$sc[$k]['check'] = 0;
				$map4['mtime'] = array('in',$ctime2);
				$map4['score_id'] = $v['id'];
				$map4['ktime'] = $notes['ktime'];
				$entry1 = M('entry')->where($map4)->select();
				if(empty($entry1)){
					$sc[$k]['work'] = 70;
				}else{
					foreach($entry1 as $Key8 => $val8){
						$entry2[] = $val8['score'];
					}
					$work2 = array_sum($entry2);
					$sc[$k]['work'] = 70 + $work2;
				}
				$sc[$k]['sum'] = $sc[$k]['public'] + $sc[$k]['part'] + $sc[$k]['price'] + $sc[$k]['check'] + $sc[$k]['work'];
			}
			$map5['posts'] = $posts_id;
			$map5['ktime'] = $year;
			$class = M('class')->where($map5)->select();
			foreach($sc as $key9 => $val9){
				if($val9['sum'] >= $class['0']['bottom'] && $val9['sum'] < $class['0']['top']){
					$sc[$key9]['dang'] = '优秀';
				}elseif($val9['sum'] >= $class['1']['bottom'] && $val9['sum'] < $class['1']['top']){
					$sc[$key9]['dang'] = '良好';
				}elseif($val9['sum'] >= $class['2']['bottom'] && $val9['sum'] < $class['2']['top']){
					$sc[$key9]['dang'] = '一般';
				}elseif($val9['sum'] >= $class['3']['bottom'] && $val9['sum'] < $class['3']['top']){
					$sc[$key9]['dang'] = '差';
				}
			}
			// 排序
			$sums = array();
			foreach($sc as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$sc);
			// echo "<pre>";
			// var_dump($sc);
			// echo "</pre>";die;
			$this->assign('notes_id',$id);
			$this->assign('pos',$posts_id);
			$this->assign('score',$sc);
			$this->display();
		}elseif(empty($entry)){
			// 计算detail表中的数据
			foreach($detail as $key => $val){
				$p_id1[] = $val['p_id'];
			}
			$p_id = array_unique($p_id1);
			foreach($sc as $k => $v){
				foreach($p_id as $key1 => $val1){
					if($val1 == '7'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '7';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key3 => $val3){
								$pub[] = $val3['score'];
							}
							$public = array_sum($pub);
							$sc[$k]['public'] = 10 + $public;
						}else{
							$sc[$k]['public'] = 10;
						}
					}elseif($val1 == '8'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '8';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key4 => $val4){
								$par[] = $val4['score'];
							}
							$part = array_sum($par);
							$sc[$k]['part'] = 10 + $part;
						}else{
							$sc[$k]['part'] = 10;
						}
					}elseif($val1 == '9'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '9';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key5 => $val5){
								$pric[] = $val5['score'];
							}
							$price = array_sum($pric);
							$sc[$k]['price'] = 0 + $price;
						}else{
							$sc[$k]['price'] = 0;
						}
					}elseif($val1 == '10'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '10';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key6 => $val6){
								$cscore[] = $val6['score'];
							}
							$zscore = array_sum($cscore);
							$sc[$k]['check'] = 0 + $zscore;
						}else{
							$sc[$k]['check'] = 0;
						}
					}elseif($val1 == '11'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '11';
						$map3['ktime'] = $notes['ktime'];
						$detail1 = M('detail')->where($map3)->select();
						if(!empty($detail1)){
							$sc[$k]['work'] = 70;
						}else{
							foreach($detail1 as $key7 => $val7){
								$detail2[] = $val7['score'];
							}
							$work1 = array_sum($detail2);
							$sc[$k]['work'] = 70 + $work1;
						}
					}
				}
				$sc[$k]['sum'] = $sc[$k]['public'] + $sc[$k]['part'] + $sc[$k]['price'] + $sc[$k]['check'] + $sc[$k]['work'];
			}
			$map5['posts'] = $posts_id;
			$map5['ktime'] = $year;
			$class = M('class')->where($map5)->select();
			foreach($sc as $key9 => $val9){
				if($val9['sum'] >= $class['0']['bottom'] && $val9['sum'] < $class['0']['top']){
					$sc[$key9]['dang'] = '优秀';
				}elseif($val9['sum'] >= $class['1']['bottom'] && $val9['sum'] < $class['1']['top']){
					$sc[$key9]['dang'] = '良好';
				}elseif($val9['sum'] >= $class['2']['bottom'] && $val9['sum'] < $class['2']['top']){
					$sc[$key9]['dang'] = '一般';
				}elseif($val9['sum'] >= $class['3']['bottom'] && $val9['sum'] < $class['3']['top']){
					$sc[$key9]['dang'] = '差';
				}
			}
			// 排序
			$sums = array();
			foreach($sc as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$sc);
			// echo "<pre>";
			// var_dump($sc);
			// echo "</pre>";die;
			$this->assign('notes_id',$id);
			$this->assign('pos',$posts_id);
			$this->assign('score',$sc);
			$this->display();
		}else{
			// 计算detail表和entry表中的数据和
			foreach($detail as $key => $val){
				$p_id1[] = $val['p_id'];
			}
			$p_id = array_unique($p_id1);
			foreach($sc as $k => $v){
				foreach($p_id as $key1 => $val1){
					if($val1 == '7'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '7';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key3 => $val3){
								$pub[] = $val3['score'];
							}
							$public = array_sum($pub);
							$sc[$k]['public'] = 10 + $public;
						}else{
							$sc[$k]['public'] = 10;
						}
					}elseif($val1 == '8'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '8';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key4 => $val4){
								$par[] = $val4['score'];
							}
							$part = array_sum($par);
							$sc[$k]['part'] = 10 + $part;
						}else{
							$sc[$k]['part'] = 10;
						}
					}elseif($val1 == '9'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '9';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key5 => $val5){
								$pric[] = $val5['score'];
							}
							$price = array_sum($pric);
							$sc[$k]['price'] = 0 + $price;
						}else{
							$sc[$k]['price'] = 0;
						}
					}elseif($val1 == '10'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '10';
						$map3['ktime'] = $notes['ktime'];
						$zhi = M('detail')->where($map3)->select();
						if(!empty($zhi)){
							foreach($zhi as $key6 => $val6){
								$cscore[] = $val6['score'];
							}
							$zscore = array_sum($cscore);
							$sc[$k]['check'] = 0 + $zscore;
						}else{
							$sc[$k]['check'] = 0;
						}
					}elseif($val1 == '11'){
						$map3['mtime'] = array('in',$ctime1);
						$map3['score_id'] = $v['id'];
						$map3['p_id'] = '11';
						$map3['ktime'] = $notes['ktime'];
						$map4['mtime'] = array('in',$ctime2);
						$map4['score_id'] = $v['id'];
						$map4['ktime'] = $notes['ktime'];
						$detail1 = M('detail')->where($map3)->select();
						$entry1 = M('entry')->where($map4)->select();
						if(empty($detail1) && empty($entry1)){
							$sc[$k]['work'] = 70;
						}elseif(empty($detail1)){
							foreach($entry1 as $Key8 => $val8){
								$entry2[] = $val8['score'];
							}
							$work2 = array_sum($entry2);
							$sc[$k]['work'] = 70 + $work2;
						}elseif(empty($entry1)){
							foreach($detail1 as $key7 => $val7){
								$detail2[] = $val7['score'];
							}
							$work1 = array_sum($detail2);
							$sc[$k]['work'] = 70 + $work1;
						}else{
							foreach($detail1 as $key7 => $val7){
								$detail2[] = $val7['score'];
							}
							$work1 = array_sum($detail2);
							foreach($entry1 as $Key8 => $val8){
								$entry2[] = $val8['score'];
							}
							$work2 = array_sum($entry2);
							$sc[$k]['work'] = 70 + $work1 + $work2;
						}
					}
				}
				$sc[$k]['sum'] = $sc[$k]['public'] + $sc[$k]['part'] + $sc[$k]['price'] + $sc[$k]['check'] + $sc[$k]['work'];
			}
			$map5['posts'] = $posts_id;
			$map5['ktime'] = $year;
			$class = M('class')->where($map5)->select();
			foreach($sc as $key9 => $val9){
				if($val9['sum'] >= $class['0']['bottom'] && $val9['sum'] < $class['0']['top']){
					$sc[$key9]['dang'] = '优秀';
				}elseif($val9['sum'] >= $class['1']['bottom'] && $val9['sum'] < $class['1']['top']){
					$sc[$key9]['dang'] = '良好';
				}elseif($val9['sum'] >= $class['2']['bottom'] && $val9['sum'] < $class['2']['top']){
					$sc[$key9]['dang'] = '一般';
				}elseif($val9['sum'] >= $class['3']['bottom'] && $val9['sum'] < $class['3']['top']){
					$sc[$key9]['dang'] = '差';
				}
			}
			// 排序
			$sums = array();
			foreach($sc as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$sc);
			// echo "<pre>";
			// var_dump($sc);
			// echo "</pre>";die;
			$this->assign('notes_id',$id);
			$this->assign('pos',$posts_id);
			$this->assign('score',$sc);
			$this->display();
		}
	}

	// 第一个图 年份记录下拉框ajax请求
	public function first(){
		// var_dump($_POST);die;
		$notes_id = $_POST['id'];
		$notes = M('notes')->where('id='.$notes_id)->find();
		$ktime = $notes['ktime'];
		$ktime1 = date('Y',$ktime);
		$score = M('score')->where('test_time='.$ktime)->select();
		$count = count($score); // 此考核年份表下所有考核人员
		$posts = M('posts')->where('parent_id=0')->order('posts_id asc')->select();
		
		// 员额法官
		$posts0 = M('posts')->where('parent_id='.$posts['0']['posts_id'])->select();
		foreach($posts0 as $k0 => $v0){
			$posts00[] = $v0['posts_id'];
		}
		$map0['posts_id'] = array('in',$posts00);
		$map0['test_time'] = $ktime;
		$score0 = M('score')->where($map0)->select();
		// var_dump($score0);die;
		$count0 = count($score0); // 员额法官人数
		$mp0['ktime'] = $ktime1;
		$mp0['posts'] = $posts['0']['posts_id'];
		$class0 = M('class')->where($mp0)->order('class_id asc')->select();
		foreach($score0 as $key0 => $val0){
			if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
				$sum01[] = $val0['sum'];
				$count01 = count($sum01);
				$bfb = $count01 / $count0 * '100%';
				$bfb01 = round($bfb,2);
			}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
				$sum02[] = $val0['sum'];
				$count02 = count($sum02);
				$bfb = $count02 / $count0 * '100%';
				$bfb02 = round($bfb,2);
			}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
				$sum03[] = $val0['sum'];
				$count03 = count($sum03);
				$bfb = $count03 / $count0 * '100%';
				$bfb03 = round($bfb,2);
			}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
				$sum04[] = $val0['sum'];
				$count04 = count($sum04);
				$bfb = $count04 / $count0 * '100%';
				$bfb04 = round($bfb,2);
			}
		}
		if(empty($bfb01)){
			$bfb01 = 0;
		}
		if(empty($bfb02)){
			$bfb02 = 0;
		}
		if(empty($bfb03)){
			$bfb03 = 0;
		}
		if(empty($bfb04)){
			$bfb04 = 0;
		}
		$list0['0'] = $bfb01;
		$list0['1'] = $bfb02;
		$list0['2'] = $bfb03;
		$list0['3'] = $bfb04;
		// var_dump($list0);die;
		
		// 司法行政人员
		$posts1 = M('posts')->where('parent_id='.$posts['1']['posts_id'])->select();
		foreach($posts1 as $k1 => $v1){
			$posts11[] = $v1['posts_id'];
		}
		$map1['posts_id'] = array('in',$posts11);
		$map1['test_time'] = $ktime;
		$score1 = M('score')->where($map1)->select();
		$count1 = count($score1); // 司法行政人员人数
		$mp1['ktime'] = $ktime1;
		$mp1['posts'] = $posts['1']['posts_id'];
		$class1 = M('class')->where($mp1)->order('class_id asc')->select();
		foreach($score1 as $key1 => $val1){
			if($val1['sum'] >= $class1['0']['bottom'] && $val1['sum'] < $class1['0']['top']){
				$sum11[] = $val1['sum'];
				$count11 = count($sum11);
				$bfb = $count11 / $count1 * '100%';
				$bfb11 = round($bfb,2);
			}elseif($val1['sum'] >= $class1['1']['bottom'] && $val1['sum'] < $class1['1']['top']){
				$sum12[] = $val1['sum'];
				$count12 = count($sum12);
				$bfb = $count12 / $count1 * '100%';
				$bfb12 = round($bfb,2);
			}elseif($val1['sum'] >= $class1['2']['bottom'] && $val1['sum'] < $class1['2']['top']){
				$sum13[] = $val1['sum'];
				$count13 = count($sum13);
				$bfb = $count13 / $count1 * '100%';
				$bfb13 = round($bfb,2);
			}elseif($val1['sum'] >= $class1['3']['bottom'] && $val1['sum'] < $class1['3']['top']){
				$sum14[] = $val1['sum'];
				$count14 = count($sum14);
				$bfb = $count14 / $count1 * '100%';
				$bfb14 = round($bfb,2);
			}
		}
		if(empty($bfb11)){
			$bfb11 = 0;
		}
		if(empty($bfb12)){
			$bfb12 = 0;
		}
		if(empty($bfb13)){
			$bfb13 = 0;
		}
		if(empty($bfb14)){
			$bfb14 = 0;
		}
		$list1['0'] = $bfb11;
		$list1['1'] = $bfb12;
		$list1['2'] = $bfb13;
		$list1['3'] = $bfb14;

		// 司法辅助人员
		$posts2 = M('posts')->where('parent_id='.$posts['2']['posts_id'])->select();
		foreach($posts2 as $k2 => $v2){
			$posts22[] = $v2['posts_id'];
		}
		$map2['posts_id'] = array('in',$posts22);
		$map2['test_time'] = $ktime;
		$score2 = M('score')->where($map2)->select();
		$count2 = count($score2); // 司法辅助人员人数
		$mp2['ktime'] = $ktime1;
		$mp2['posts'] = $posts['2']['posts_id'];
		$class2 = M('class')->where($mp2)->order('class_id asc')->select();
		foreach($score2 as $key2 => $val2){
			if($val2['sum'] >= $class2['0']['bottom'] && $val2['sum'] < $class2['0']['top']){
				$sum21[] = $val2['sum'];
				$count21 = count($sum21);
				$bfb = $count21 / $count2 * '100%';
				$bfb21 = round($bfb,2);
			}elseif($val2['sum'] >= $class2['1']['bottom'] && $val2['sum'] < $class2['1']['top']){
				$sum22[] = $val2['sum'];
				$count22 = count($sum22);
				$bfb = $count22 / $count2 * '100%';
				$bfb22 = round($bfb,2);
			}elseif($val2['sum'] >= $class2['2']['bottom'] && $val2['sum'] < $class2['2']['top']){
				$sum23[] = $val2['sum'];
				$count23 = count($sum23);
				$bfb = $count23 / $count2 * '100%';
				$bfb23 = round($bfb,2);
			}elseif($val2['sum'] >= $class2['3']['bottom'] && $val2['sum'] < $class2['3']['top']){
				$sum24[] = $val2['sum'];
				$count24 = count($sum24);
				$bfb = $count24 / $count2 * '100%';
				$bfb24 = round($bfb,2);
			}
		}
		if(empty($bfb21)){
			$bfb21 = 0;
		}
		if(empty($bfb22)){
			$bfb22 = 0;
		}
		if(empty($bfb23)){
			$bfb23 = 0;
		}
		if(empty($bfb24)){
			$bfb24 = 0;
		}
		$list2['0'] = $bfb21;
		$list2['1'] = $bfb22;
		$list2['2'] = $bfb23;
		$list2['3'] = $bfb24;
		
		// 所有人分析
		$num1 = $count01 + $count11 + $count21;
		$bf1 = $num1 / $count * '100%';
		$bfb1 = round($bf1,2);
		$num2 = $count02 + $count12 + $count22;
		$bf2 = $num2 / $count * '100%';
		$bfb2 = round($bf2,2);
		$num3 = $count03 + $count13 + $count23;
		$bf3 = $num3 / $count * '100%';
		$bfb3 = round($bf3,2);
		$num4 = $count04 + $count14 + $count24;
		$bf4 = $num4 / $count * '100%';
		$bfb4 = round($bf4,2);
		if(empty($bfb1)){
			$bfb1 = 0;
		}
		if(empty($bfb2)){
			$bfb2 = 0;
		}
		if(empty($bfb3)){
			$bfb3 = 0;
		}
		if(empty($bfb4)){
			$bfb4 = 0;
		}
		$list['0'] = $bfb1;
		$list['1'] = $bfb2;
		$list['2'] = $bfb3;
		$list['3'] = $bfb4;
		$list0 = implode(',',$list0);
		$list1 = implode(',',$list1);
		$list2 = implode(',',$list2);
		$list = implode(',',$list);
		$this->assign('list0',$list0);
		$this->assign('list1',$list1);
		$this->assign('list2',$list2);
		$this->assign('list',$list);
		$this->display();
	}

	// 第二个图 年份记录下拉框ajax请求
	public function second(){
		// var_dump($_POST);die;
		$notes_id = $_POST['id'];
		$notes = M('notes')->where('id='.$notes_id)->find();
		$ktime = $notes['ktime'];
		$ktime1 = date('Y',$ktime);
		$score = M('score')->where('test_time='.$ktime)->select();
		$posts = M('posts')->where('parent_id = 0')->order('posts_id asc')->select();
		// 员额法官
		$posts0 = M('posts')->where('parent_id='.$posts['0']['posts_id'])->select();
		foreach($posts0 as $k0 => $v0){
			$posts00[] = $v0['posts_id'];
		}
		$map0['posts_id'] = array('in',$posts00);
		$map0['test_time'] = $ktime;
		$score0 = M('score')->where($map0)->select();
		// 司法行政人员
		$posts1 = M('posts')->where('parent_id='.$posts['1']['posts_id'])->select();
		foreach($posts1 as $k1 => $v1){
			$posts11[] = $v1['posts_id'];
		}
		$map1['posts_id'] = array('in',$posts11);
		$map1['test_time'] = $ktime;
		$score1 = M('score')->where($map1)->select();
		// 司法辅助人员
		$posts2 = M('posts')->where('parent_id='.$posts['2']['posts_id'])->select();
		foreach($posts2 as $k2 => $v2){
			$posts22[] = $v2['posts_id'];
		}
		$map2['posts_id'] = array('in',$posts22);
		$map2['test_time'] = $ktime;
		$score2 = M('score')->where($map2)->select();
		// 一月 开始 
		$ktime2 = $ktime1 . '-' . '01'; // 考核年月
		$ktime3 = strtotime($ktime2); // 考核年月时间戳 一月
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where0['ktime'] = $ktime;
		$where0['mtime'] = $ktime3;
		$where0['score_id'] = array('in',$yuan_id);
		$where01['ktime'] = $ktime;
		$where01['mtime'] = $ktime2;
		$where01['score_id'] = array('in',$yuan_id);
		$detail = M('detail')->where($where0)->select();
		$entry = M('entry')->where($where01)->select();
		if(empty($detail) && empty($entry)){
			// 默认值
			$ycount0 = count($score0);
			$ysum0 = $ycount0 * 90;
			$pyuan01 = $ysum0 / $ycount0;
		}else{
			if(empty($detail)){
				// 计算entry表中的数据
				foreach($entry as $key31 => $value31){
					$entry01[] = $value31['score'];
				}
				$cha01 = array_sum($entry01);
				$ycount0 = count($score0);
				$ysum0 = $ycount0 * 90 + $cha01;
				$pyuan01 = round($ysum0 / $ycount0,2);
			}elseif(empty($entry)){
				// 计算detail表中的数据
				foreach($detail as $key32 => $value32){
					$detail01[] = $value32['score'];
				}
				$cha01 = array_sum($detail01);
				$ycount0 = count($score0);
				$ysum0 = $ycount0 * 90 + $cha01;
				$pyuan01 = round($ysum0 / $ycount0,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail as $key33 => $value33){
					$detail01[] = $value33['score'];
				}
				foreach($entry as $key33 => $value33){
					$entry01[] = $value33['score'];
				}
				$chaz011 = array_sum($detail01);
				$chaz012 = array_sum($entry01);
				$cha01 = $chaz011 + $chaz012;
				$ycount0 = count($score0);
				$ysum0 = $ycount0 * 90 + $cha01;
				$pyuan01 = round($ysum0 / $ycount0,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where1['ktime'] = $ktime;
		$where1['mtime'] = $ktime3;
		$where1['score_id'] = array('in',$xinz_id);
		$where11['ktime'] = $ktime;
		$where11['mtime'] = $ktime2;
		$where11['score_id'] = array('in',$xinz_id);
		$detail1 = M('detail')->where($where1)->select();
		$entry1 = M('entry')->where($where11)->select();
		if(empty($detail1) && empty($entry1)){
			// 默认值
			$xcount1 = count($score1);
			$xsum1 = $xcount1 * 90;
			$pxinz11 = $xsum1 / $xcount1;
		}else{
			if(empty($detail1)){
				// 计算entry表中的数据
				foreach($entry1 as $key41 => $value41){
					$entry11[] = $value41['score'];
				}
				$cha11 = array_sum($entry11);
				$xcount1 = count($score1);
				$xsum1 = $xcount1 * 90 + $cha11;
				$pxinz11 = round($xsum1 / $xcount1,2);
			}elseif(empty($entry1)){
				// 计算detail表中的数据
				foreach($detail1 as $key42 => $value42){
					$detail11[] = $value42['score'];
				}
				$cha11 = array_sum($detail11);
				$xcount1 = count($score1);
				$xsum1 = $xcount1 * 90 + $cha11;
				$pxinz11 = round($xsum1 / $xcount1,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail1 as $key43 => $value43){
					$detail11[] = $value43['score'];
				}
				foreach($entry1 as $key43 => $value43){
					$entry11[] = $value43['score'];
				}
				$chaz111 = array_sum($detail11);
				$chaz112 = array_sum($entry11);
				$cha11 = $chaz111 + $chaz112;
				$xcount1 = count($score1);
				$xsum1 = $xcount1 * 90 + $cha11;
				$pxinz11 = round($xsum1 / $xcount1,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where2['ktime'] = $ktime;
		$where2['mtime'] = $ktime3;
		$where2['score_id'] = array('in',$fuz_id);
		$where21['ktime'] = $ktime;
		$where21['mtime'] = $ktime2;
		$where21['score_id'] = array('in',$fuz_id);
		$detail2 = M('detail')->where($where2)->select();
		$entry2 = M('entry')->where($where21)->select();
		if(empty($detail2) && empty($entry2)){
			// 默认值
			$fcount2 = count($score2);
			$fsum2 = $fcount2 * 90;
			$pfuz22 = $fsum2 / $fcount2;
		}else{
			if(empty($detail2)){
				// 计算entry表中的数据
				foreach($entry2 as $key51 => $value51){
					$entry22[] = $value51['score'];
				}
				$cha21 = array_sum($entry22);
				$fcount2 = count($score2);
				$fsum2 = $fcount2 * 90 + $cha21;
				$pfuz22 = round($fsum2 / $fcount2,2);
			}elseif(empty($entry2)){
				// 计算detail表中的数据
				foreach($detail2 as $key52 => $value52){
					$detail22[] = $value52['score'];
				}
				$cha22 = array_sum($detail22);
				$fcount2 = count($score2);
				$fsum2 = $fcount2 * 90 + $cha22;
				$pfuz22 = round($fsum2 / $fcount2,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail2 as $key53 => $value53){
					$detail22[] = $value53['score'];
				}
				foreach($entry2 as $key53 => $value53){
					$entry22[] = $value53['score'];
				}
				$chaz211 = array_sum($detail22);
				$chaz212 = array_sum($entry22);
				$cha22 = $chaz211 + $chaz212;
				$fcount2 = count($score2);
				$fsum2 = $fcount2 * 90 + $cha22;
				$pfuz22 = round($fsum2 / $fcount2,2);
			}
		}
		// 一月 结束
		$yuan['0'] = $pyuan01;
		$xinz['0'] = $pxinz11;
		$fuz['0'] = $pfuz22;

		// 二月 开始
		for($i = 1;$i <= 2;$i++){
			$a[] = $i;
		}
		foreach($a as $k => $v){
			$ktime4[] = $ktime1 . '-0' . $v;
			$ktime5[] = strtotime($ktime1 . '-' . $v);
		}
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where2['ktime'] = $ktime;
		$where2['mtime'] = array('in',$ktime5);
		$where2['score_id'] = array('in',$yuan_id);
		$where21['ktime'] = $ktime;
		$where21['mtime'] = array('in',$ktime4);
		$where21['score_id'] = array('in',$yuan_id);
		$detail2 = M('detail')->where($where2)->select();
		$entry2 = M('entry')->where($where21)->select();
		if(empty($detail2) && empty($entry2)){
			// 默认值
			$ycount2 = count($score0);
			$ysum2 = $ycount2 * 90;
			$pyuan21 = $ysum2 / $ycount2;
		}else{
			if(empty($detail2)){
				// 计算entry表中的数据
				foreach($entry2 as $key31 => $value31){
					$entry21[] = $value31['score'];
				}
				$cha21 = array_sum($entry21);
				$ycount2 = count($score0);
				$ysum2 = $ycount2 * 90 + $cha21;
				$pyuan21 = round($ysum2 / $ycount2,2);
			}elseif(empty($entry2)){
				// 计算detail表中的数据
				foreach($detail2 as $key32 => $value32){
					$detail21[] = $value32['score'];
				}
				$cha21 = array_sum($detail21);
				$ycount2 = count($score0);
				$ysum2 = $ycount2 * 90 + $cha21;
				$pyuan21 = round($ysum2 / $ycount2,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail2 as $key33 => $value33){
					$detail21[] = $value33['score'];
				}
				foreach($entry2 as $key33 => $value33){
					$entry21[] = $value33['score'];
				}
				$chaz211 = array_sum($detail21);
				$chaz212 = array_sum($entry21);
				$cha21 = $chaz211 + $chaz212;
				$ycount2 = count($score0);
				$ysum2 = $ycount2 * 90 + $cha21;
				$pyuan21 = round($ysum2 / $ycount2,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where22['ktime'] = $ktime;
		$where22['mtime'] = array('in',$ktime5);
		$where22['score_id'] = array('in',$xinz_id);
		$where23['ktime'] = $ktime;
		$where23['mtime'] = array('in',$ktime4);
		$where23['score_id'] = array('in',$xinz_id);
		$detail21 = M('detail')->where($where22)->select();
		$entry21 = M('entry')->where($where23)->select();
		if(empty($detail21) && empty($entry21)){
			// 默认值
			$xcount21 = count($score1);
			$xsum21 = $xcount21 * 90;
			$pxinz21 = $xsum21 / $xcount21;
		}else{
			if(empty($detail21)){
				// 计算entry表中的数据
				foreach($entry21 as $key41 => $value41){
					$entry22[] = $value41['score'];
				}
				$cha21 = array_sum($entry22);
				$xcount21 = count($score1);
				$xsum21 = $xcount21 * 90 + $cha21;
				$pxinz21 = round($xsum21 / $xcount21,2);
			}elseif(empty($entry21)){
				// 计算detail表中的数据
				foreach($detail21 as $key42 => $value42){
					$detail22[] = $value42['score'];
				}
				$cha22 = array_sum($detail22);
				$xcount21 = count($score1);
				$xsum21 = $xcount21 * 90 + $cha22;
				$pxinz21 = round($xsum21 / $xcount21,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail21 as $key43 => $value43){
					$detail22[] = $value43['score'];
				}
				foreach($entry21 as $key43 => $value43){
					$entry22[] = $value43['score'];
				}
				$chaz211 = array_sum($detail22);
				$chaz212 = array_sum($entry22);
				$cha22 = $chaz211 + $chaz212;
				$xcount21 = count($score1);
				$xsum21 = $xcount21 * 90 + $cha22;
				$pxinz21 = round($xsum21 / $xcount21,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where24['ktime'] = $ktime;
		$where24['mtime'] = array('in',$ktime5);
		$where24['score_id'] = array('in',$fuz_id);
		$where25['ktime'] = $ktime;
		$where25['mtime'] = array('in',$ktime4);
		$where25['score_id'] = array('in',$fuz_id);
		$detail22 = M('detail')->where($where24)->select();
		$entry22 = M('entry')->where($where25)->select();
		if(empty($detail22) && empty($entry22)){
			// 默认值
			$fcount22 = count($score2);
			$fsum22 = $fcount22 * 90;
			$pfuz22 = $fsum22 / $fcount22;
		}else{
			if(empty($detail22)){
				// 计算entry表中的数据
				foreach($entry22 as $key51 => $value51){
					$entry23[] = $value51['score'];
				}
				$cha22 = array_sum($entry23);
				$fcount22 = count($score2);
				$fsum22 = $fcount22 * 90 + $cha22;
				$pfuz22 = round($fsum22 / $fcount22,2);
			}elseif(empty($entry22)){
				// 计算detail表中的数据
				foreach($detail22 as $key52 => $value52){
					$detail23[] = $value52['score'];
				}
				$cha22 = array_sum($detail23);
				$fcount22 = count($score2);
				$fsum22 = $fcount22 * 90 + $cha22;
				$pfuz22 = round($fsum22 / $fcount22,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail22 as $key53 => $value53){
					$detail23[] = $value53['score'];
				}
				foreach($entry22 as $key53 => $value53){
					$entry23[] = $value53['score'];
				}
				$chaz221 = array_sum($detail23);
				$chaz222 = array_sum($entry23);
				$cha22 = $chaz221 + $chaz222;
				$fcount22 = count($score2);
				$fsum22 = $fcount22 * 90 + $cha22;
				$pfuz22 = round($fsum22 / $fcount22,2);
			}
		}
		// 二月 结束
		$yuan['1'] = $pyuan21;
		$xinz['1'] = $pxinz21;
		$fuz['1'] = $pfuz22;
		
		// 三月 开始
		for($i = 1;$i <= 3;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime6[] = $ktime1 . '-0' . $v;
			$ktime7[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where30['ktime'] = $ktime;
		$where30['mtime'] = array('in',$ktime7);
		$where30['score_id'] = array('in',$yuan_id);
		$where31['ktime'] = $ktime;
		$where31['mtime'] = array('in',$ktime6);
		$where31['score_id'] = array('in',$yuan_id);
		$detail3 = M('detail')->where($where30)->select();
		$entry3 = M('entry')->where($where31)->select();
		if(empty($detail3) && empty($entry3)){
			// 默认值
			$ycount3 = count($score0);
			$ysum3 = $ycount3 * 90;
			$pyuan3 = $ysum3 / $ycount3;
		}else{
			if(empty($detail3)){
				// 计算entry表中的数据
				foreach($entry3 as $key31 => $value31){
					$entry31[] = $value31['score'];
				}
				$cha3 = array_sum($entry31);
				$ycount3 = count($score0);
				$ysum3= $ycount3 * 90 + $cha3;
				$pyuan3 = round($ysum3 / $ycount3,2);
			}elseif(empty($entry3)){
				// 计算detail表中的数据
				foreach($detail3 as $key32 => $value32){
					$detail31[] = $value32['score'];
				}
				$cha3 = array_sum($detail31);
				$ycount3 = count($score0);
				$ysum3 = $ycount3 * 90 + $cha3;
				$pyuan3 = round($ysum3 / $ycount3,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail3 as $key33 => $value33){
					$detail31[] = $value33['score'];
				}
				foreach($entry3 as $key33 => $value33){
					$entry31[] = $value33['score'];
				}
				$chaz311 = array_sum($detail31);
				$chaz312 = array_sum($entry31);
				$cha3 = $chaz311 + $chaz312;
				$ycount3 = count($score0);
				$ysum3 = $ycount3 * 90 + $cha3;
				$pyuan3 = round($ysum3 / $ycount3,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where32['ktime'] = $ktime;
		$where32['mtime'] = array('in',$ktime7);
		$where32['score_id'] = array('in',$xinz_id);
		$where33['ktime'] = $ktime;
		$where33['mtime'] = array('in',$ktime6);
		$where33['score_id'] = array('in',$xinz_id);
		$detail31 = M('detail')->where($where32)->select();
		$entry31 = M('entry')->where($where33)->select();
		if(empty($detail31) && empty($entry31)){
			// 默认值
			$xcount3 = count($score1);
			$xsum3 = $xcount3 * 90;
			$pxinz3 = $xsum3 / $xcount3;
		}else{
			if(empty($detail31)){
				// 计算entry表中的数据
				foreach($entry31 as $key41 => $value41){
					$entry32[] = $value41['score'];
				}
				$cha3 = array_sum($entry32);
				$xcount3 = count($score1);
				$xsum3 = $xcount3 * 90 + $cha3;
				$pxinz3 = round($xsum3 / $xcount3,2);
			}elseif(empty($entry31)){
				// 计算detail表中的数据
				foreach($detail31 as $key42 => $value42){
					$detail32[] = $value42['score'];
				}
				$cha3 = array_sum($detail32);
				$xcount3 = count($score1);
				$xsum3 = $xcount3 * 90 + $cha3;
				$pxinz3 = round($xsum3 / $xcount3,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail31 as $key43 => $value43){
					$detail32[] = $value43['score'];
				}
				foreach($entry31 as $key43 => $value43){
					$entry32[] = $value43['score'];
				}
				$chaz311 = array_sum($detail32);
				$chaz312 = array_sum($entry32);
				$cha3 = $chaz311 + $chaz312;
				$xcount3 = count($score1);
				$xsum3 = $xcount3 * 90 + $cha3;
				$pxinz3 = round($xsum3 / $xcount3,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where34['ktime'] = $ktime;
		$where34['mtime'] = array('in',$ktime7);
		$where34['score_id'] = array('in',$fuz_id);
		$where35['ktime'] = $ktime;
		$where35['mtime'] = array('in',$ktime6);
		$where35['score_id'] = array('in',$fuz_id);
		$detail32 = M('detail')->where($where34)->select();
		$entry32 = M('entry')->where($where35)->select();
		if(empty($detail32) && empty($entry32)){
			// 默认值
			$fcount3 = count($score2);
			$fsum3 = $fcount3 * 90;
			$pfuz3 = $fsum3 / $fcount3;
		}else{
			if(empty($detail32)){
				// 计算entry表中的数据
				foreach($entry32 as $key51 => $value51){
					$entry33[] = $value51['score'];
				}
				$cha3 = array_sum($entry33);
				$fcount3 = count($score2);
				$fsum3 = $fcount3 * 90 + $cha3;
				$pfuz3 = round($fsum3 / $fcount3,2);
			}elseif(empty($entry32)){
				// 计算detail表中的数据
				foreach($detail32 as $key52 => $value52){
					$detail33[] = $value52['score'];
				}
				$cha3 = array_sum($detail33);
				$fcount3 = count($score2);
				$fsum3 = $fcount3 * 90 + $cha3;
				$pfuz3 = round($fsum3 / $fcount3,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail32 as $key53 => $value53){
					$detail33[] = $value53['score'];
				}
				foreach($entry32 as $key53 => $value53){
					$entry33[] = $value53['score'];
				}
				$chaz321 = array_sum($detail33);
				$chaz322 = array_sum($entry33);
				$cha3 = $chaz321 + $chaz322;
				$fcount3 = count($score2);
				$fsum3 = $fcount3 * 90 + $cha3;
				$pfuz3 = round($fsum3 / $fcount3,2);
			}
		}
		// 三月 结束
		$yuan['2'] = $pyuan3;
		$xinz['2'] = $pxinz3;
		$fuz['2'] = $pfuz3;
		
		// 四月 开始
		for($i = 1;$i <= 4;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime8[] = $ktime1 . '-0' . $v;
			$ktime9[] = strtotime($ktime1 . '-' . $v);
		}
		// var_dump($ktime6);
		// var_dump($ktime7);die;
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where40['ktime'] = $ktime;
		$where40['mtime'] = array('in',$ktime9);
		$where40['score_id'] = array('in',$yuan_id);
		$where41['ktime'] = $ktime;
		$where41['mtime'] = array('in',$ktime8);
		$where41['score_id'] = array('in',$yuan_id);
		$detail4 = M('detail')->where($where40)->select();
		$entry4 = M('entry')->where($where41)->select();
		if(empty($detail4) && empty($entry4)){
			// 默认值
			$ycount4 = count($score0);
			$ysum4 = $ycount4 * 90;
			$pyuan4 = $ysum4 / $ycount4;
		}else{
			if(empty($detail4)){
				// 计算entry表中的数据
				foreach($entry4 as $key31 => $value31){
					$entry41[] = $value31['score'];
				}
				$cha4 = array_sum($entry41);
				$ycount4 = count($score0);
				$ysum4 = $ycount4 * 90 + $cha4;
				$pyuan4 = round($ysum4 / $ycount4,2);
			}elseif(empty($entry4)){
				// 计算detail表中的数据
				foreach($detail4 as $key32 => $value32){
					$detail41[] = $value32['score'];
				}
				$cha4 = array_sum($detail31);
				$ycount4 = count($score0);
				$ysum4 = $ycount4 * 90 + $cha4;
				$pyuan4 = round($ysum4 / $ycount4,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail4 as $key33 => $value33){
					$detail41[] = $value33['score'];
				}
				foreach($entry4 as $key33 => $value33){
					$entry41[] = $value33['score'];
				}
				$chaz411 = array_sum($detail41);
				$chaz412 = array_sum($entry41);
				$cha4 = $chaz411 + $chaz412;
				$ycount4 = count($score0);
				$ysum4 = $ycount4 * 90 + $cha4;
				$pyuan4 = round($ysum4 / $ycount4,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where42['ktime'] = $ktime;
		$where42['mtime'] = array('in',$ktime9);
		$where42['score_id'] = array('in',$xinz_id);
		$where43['ktime'] = $ktime;
		$where43['mtime'] = array('in',$ktime8);
		$where43['score_id'] = array('in',$xinz_id);
		$detail41 = M('detail')->where($where42)->select();
		$entry41 = M('entry')->where($where43)->select();
		if(empty($detail41) && empty($entry41)){
			// 默认值
			$xcount4 = count($score1);
			$xsum4 = $xcount4 * 90;
			$pxinz4 = $xsum4 / $xcount4;
		}else{
			if(empty($detail41)){
				// 计算entry表中的数据
				foreach($entry41 as $key41 => $value41){
					$entry42[] = $value41['score'];
				}
				$cha4 = array_sum($entry42);
				$xcount4 = count($score1);
				$xsum4 = $xcount4 * 90 + $cha4;
				$pxinz4 = round($xsum4 / $xcount4,2);
			}elseif(empty($entry41)){
				// 计算detail表中的数据
				foreach($detail41 as $key42 => $value42){
					$detail42[] = $value42['score'];
				}
				$cha4 = array_sum($detail42);
				$xcount4 = count($score1);
				$xsum4 = $xcount4 * 90 + $cha4;
				$pxinz4 = round($xsum4 / $xcount4,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail41 as $key43 => $value43){
					$detail42[] = $value43['score'];
				}
				foreach($entry41 as $key43 => $value43){
					$entry42[] = $value43['score'];
				}
				$chaz411 = array_sum($detail42);
				$chaz412 = array_sum($entry42);
				$cha4 = $chaz411 + $chaz412;
				$xcount4 = count($score1);
				$xsum4 = $xcount3 * 90 + $cha3;
				$pxinz4 = round($xsum4 / $xcount4,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where44['ktime'] = $ktime;
		$where44['mtime'] = array('in',$ktime9);
		$where44['score_id'] = array('in',$fuz_id);
		$where45['ktime'] = $ktime;
		$where45['mtime'] = array('in',$ktime8);
		$where45['score_id'] = array('in',$fuz_id);
		$detail42 = M('detail')->where($where44)->select();
		$entry42 = M('entry')->where($where45)->select();
		if(empty($detail42) && empty($entry42)){
			// 默认值
			$fcount4 = count($score2);
			$fsum4 = $fcount4 * 90;
			$pfuz4 = $fsum4 / $fcount4;
		}else{
			if(empty($detail42)){
				// 计算entry表中的数据
				foreach($entry42 as $key51 => $value51){
					$entry43[] = $value51['score'];
				}
				$cha4 = array_sum($entry43);
				$fcount4 = count($score2);
				$fsum4 = $fcount4 * 90 + $cha4;
				$pfuz4 = round($fsum4 / $fcount4,2);
			}elseif(empty($entry42)){
				// 计算detail表中的数据
				foreach($detail42 as $key52 => $value52){
					$detail43[] = $value52['score'];
				}
				$cha4 = array_sum($detail43);
				$fcount4 = count($score2);
				$fsum4 = $fcount4 * 90 + $cha4;
				$pfuz4 = round($fsum4 / $fcount4,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail42 as $key53 => $value53){
					$detail43[] = $value53['score'];
				}
				foreach($entry42 as $key53 => $value53){
					$entry43[] = $value53['score'];
				}
				$chaz421 = array_sum($detail43);
				$chaz422 = array_sum($entry43);
				$cha4 = $chaz421 + $chaz422;
				$fcount4 = count($score2);
				$fsum4 = $fcount4 * 90 + $cha4;
				$pfuz4 = round($fsum4 / $fcount4,2);
			}
		}
		// 四月 结束
		$yuan['3'] = $pyuan4;
		$xinz['3'] = $pxinz4;
		$fuz['3'] = $pfuz4;

		// 五月 开始
		for($i = 1;$i <= 5;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime10[] = $ktime1 . '-0' . $v;
			$ktime11[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where50['ktime'] = $ktime;
		$where50['mtime'] = array('in',$ktime11);
		$where50['score_id'] = array('in',$yuan_id);
		$where51['ktime'] = $ktime;
		$where51['mtime'] = array('in',$ktime10);
		$where51['score_id'] = array('in',$yuan_id);
		$detail5 = M('detail')->where($where50)->select();
		$entry5 = M('entry')->where($where51)->select();
		if(empty($detail5) && empty($entry5)){
			// 默认值
			$ycount5 = count($score0);
			$ysum5 = $ycount5 * 90;
			$pyuan5 = $ysum5 / $ycount5;
		}else{
			if(empty($detail5)){
				// 计算entry表中的数据
				foreach($entry5 as $key31 => $value31){
					$entry51[] = $value31['score'];
				}
				$cha5 = array_sum($entry51);
				$ycount5 = count($score0);
				$ysum5 = $ycount5 * 90 + $cha5;
				$pyuan5 = round($ysum5 / $ycount5,2);
			}elseif(empty($entry5)){
				// 计算detail表中的数据
				foreach($detail5 as $key32 => $value32){
					$detail51[] = $value32['score'];
				}
				$cha5 = array_sum($detail51);
				$ycount5 = count($score0);
				$ysum5 = $ycount5 * 90 + $cha5;
				$pyuan5 = round($ysum5 / $ycount5,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail5 as $key33 => $value33){
					$detail51[] = $value33['score'];
				}
				foreach($entry5 as $key33 => $value33){
					$entry51[] = $value33['score'];
				}
				$chaz511 = array_sum($detail51);
				$chaz512 = array_sum($entry51);
				$cha5 = $chaz511 + $chaz512;
				$ycount5 = count($score0);
				$ysum5 = $ycount5 * 90 + $cha5;
				$pyuan5 = round($ysum5 / $ycount5,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where52['ktime'] = $ktime;
		$where52['mtime'] = array('in',$ktime11);
		$where52['score_id'] = array('in',$xinz_id);
		$where53['ktime'] = $ktime;
		$where53['mtime'] = array('in',$ktime10);
		$where53['score_id'] = array('in',$xinz_id);
		$detail51 = M('detail')->where($where52)->select();
		$entry51 = M('entry')->where($where53)->select();
		if(empty($detail51) && empty($entry51)){
			// 默认值
			$xcount5 = count($score1);
			$xsum5 = $xcount5 * 90;
			$pxinz5 = $xsum5 / $xcount5;
		}else{
			if(empty($detail51)){
				// 计算entry表中的数据
				foreach($entry51 as $key41 => $value41){
					$entry52[] = $value41['score'];
				}
				$cha5 = array_sum($entry52);
				$xcount5 = count($score1);
				$xsum5 = $xcount5 * 90 + $cha5;
				$pxinz5 = round($xsum5 / $xcount5,2);
			}elseif(empty($entry51)){
				// 计算detail表中的数据
				foreach($detail51 as $key42 => $value42){
					$detail52[] = $value42['score'];
				}
				$cha5 = array_sum($detail52);
				$xcount5 = count($score1);
				$xsum5 = $xcount5 * 90 + $cha5;
				$pxinz5 = round($xsum5 / $xcount5,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail51 as $key43 => $value43){
					$detail52[] = $value43['score'];
				}
				foreach($entry51 as $key43 => $value43){
					$entry52[] = $value43['score'];
				}
				$chaz511 = array_sum($detail52);
				$chaz512 = array_sum($entry52);
				$cha5 = $chaz511 + $chaz512;
				$xcount5 = count($score1);
				$xsum5 = $xcount5 * 90 + $cha5;
				$pxinz5 = round($xsum5 / $xcount5,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where54['ktime'] = $ktime;
		$where54['mtime'] = array('in',$ktime11);
		$where54['score_id'] = array('in',$fuz_id);
		$where55['ktime'] = $ktime;
		$where55['mtime'] = array('in',$ktime10);
		$where55['score_id'] = array('in',$fuz_id);
		$detail52 = M('detail')->where($where54)->select();
		$entry52 = M('entry')->where($where55)->select();
		if(empty($detail52) && empty($entry52)){
			// 默认值
			$fcount5 = count($score2);
			$fsum5 = $fcount5 * 90;
			$pfuz5 = $fsum5 / $fcount5;
		}else{
			if(empty($detail52)){
				// 计算entry表中的数据
				foreach($entry52 as $key51 => $value51){
					$entry53[] = $value51['score'];
				}
				$cha5 = array_sum($entry53);
				$fcount5 = count($score2);
				$fsum5 = $fcount5 * 90 + $cha5;
				$pfuz5 = round($fsum5 / $fcount5,2);
			}elseif(empty($entry52)){
				// 计算detail表中的数据
				foreach($detail52 as $key52 => $value52){
					$detail53[] = $value52['score'];
				}
				$cha5 = array_sum($detail53);
				$fcount5 = count($score2);
				$fsum5 = $fcount5 * 90 + $cha5;
				$pfuz5 = round($fsum5 / $fcount5,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail52 as $key53 => $value53){
					$detail53[] = $value53['score'];
				}
				foreach($entry52 as $key53 => $value53){
					$entry53[] = $value53['score'];
				}
				$chaz521 = array_sum($detail53);
				$chaz522 = array_sum($entry53);
				$cha5 = $chaz521 + $chaz522;
				$fcount5 = count($score2);
				$fsum5 = $fcount5 * 90 + $cha5;
				$pfuz5 = round($fsum5 / $fcount5,2);
			}
		}
		// 五月 结束
		$yuan['4'] = $pyuan5;
		$xinz['4'] = $pxinz5;
		$fuz['4'] = $pfuz5;

		// 六月 开始
		for($i = 1;$i <= 6;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime12[] = $ktime1 . '-0' . $v;
			$ktime13[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where60['ktime'] = $ktime;
		$where60['mtime'] = array('in',$ktime13);
		$where60['score_id'] = array('in',$yuan_id);
		$where61['ktime'] = $ktime;
		$where61['mtime'] = array('in',$ktime12);
		$where61['score_id'] = array('in',$yuan_id);
		$detail6 = M('detail')->where($where60)->select();
		$entry6 = M('entry')->where($where61)->select();
		if(empty($detail6) && empty($entry6)){
			// 默认值
			$ycount6 = count($score0);
			$ysum6 = $ycount6 * 90;
			$pyuan6 = $ysum6 / $ycount6;
		}else{
			if(empty($detail6)){
				// 计算entry表中的数据
				foreach($entry6 as $key31 => $value31){
					$entry61[] = $value31['score'];
				}
				$cha6 = array_sum($entry61);
				$ycount6 = count($score0);
				$ysum6 = $ycount6 * 90 + $cha6;
				$pyuan6 = round($ysum6 / $ycount6,2);
			}elseif(empty($entry6)){
				// 计算detail表中的数据
				foreach($detail6 as $key32 => $value32){
					$detail61[] = $value32['score'];
				}
				$cha6 = array_sum($detail61);
				$ycount6 = count($score0);
				$ysum6 = $ycount6 * 90 + $cha6;
				$pyuan6 = round($ysum6 / $ycount6,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail6 as $key33 => $value33){
					$detail61[] = $value33['score'];
				}
				foreach($entry6 as $key33 => $value33){
					$entry61[] = $value33['score'];
				}
				$chaz611 = array_sum($detail61);
				$chaz612 = array_sum($entry61);
				$cha6 = $chaz611 + $chaz612;
				$ycount6 = count($score0);
				$ysum6 = $ycount6 * 90 + $cha6;
				$pyuan6 = round($ysum6 / $ycount6,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where62['ktime'] = $ktime;
		$where62['mtime'] = array('in',$ktime13);
		$where62['score_id'] = array('in',$xinz_id);
		$where63['ktime'] = $ktime;
		$where63['mtime'] = array('in',$ktime12);
		$where63['score_id'] = array('in',$xinz_id);
		$detail61 = M('detail')->where($where62)->select();
		$entry61 = M('entry')->where($where63)->select();
		if(empty($detail61) && empty($entry61)){
			// 默认值
			$xcount6 = count($score1);
			$xsum6 = $xcount6 * 90;
			$pxinz6 = $xsum6 / $xcount6;
		}else{
			if(empty($detail61)){
				// 计算entry表中的数据
				foreach($entry61 as $key41 => $value41){
					$entry62[] = $value41['score'];
				}
				$cha6 = array_sum($entry62);
				$xcount6 = count($score1);
				$xsum6 = $xcount6 * 90 + $cha6;
				$pxinz6 = round($xsum6 / $xcount6,2);
			}elseif(empty($entry61)){
				// 计算detail表中的数据
				foreach($detail61 as $key42 => $value42){
					$detail62[] = $value42['score'];
				}
				$cha6 = array_sum($detail62);
				$xcount6 = count($score1);
				$xsum6 = $xcount6 * 90 + $cha6;
				$pxinz6 = round($xsum6 / $xcount6,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail61 as $key43 => $value43){
					$detail62[] = $value43['score'];
				}
				foreach($entry61 as $key43 => $value43){
					$entry62[] = $value43['score'];
				}
				$chaz611 = array_sum($detail62);
				$chaz612 = array_sum($entry62);
				$cha6 = $chaz611 + $chaz612;
				$xcount6 = count($score1);
				$xsum6 = $xcount6 * 90 + $cha6;
				$pxinz6 = round($xsum6 / $xcount6,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where64['ktime'] = $ktime;
		$where64['mtime'] = array('in',$ktime13);
		$where64['score_id'] = array('in',$fuz_id);
		$where65['ktime'] = $ktime;
		$where65['mtime'] = array('in',$ktime12);
		$where65['score_id'] = array('in',$fuz_id);
		$detail62 = M('detail')->where($where64)->select();
		$entry62 = M('entry')->where($where65)->select();
		if(empty($detail62) && empty($entry62)){
			// 默认值
			$fcount6 = count($score2);
			$fsum6 = $fcount6 * 90;
			$pfuz6 = $fsum6 / $fcount6;
		}else{
			if(empty($detail62)){
				// 计算entry表中的数据
				foreach($entry62 as $key51 => $value51){
					$entry63[] = $value51['score'];
				}
				$cha6 = array_sum($entry63);
				$fcount6 = count($score2);
				$fsum6 = $fcount6 * 90 + $cha6;
				$pfuz6 = round($fsum6 / $fcount6,2);
			}elseif(empty($entry62)){
				// 计算detail表中的数据
				foreach($detail62 as $key52 => $value52){
					$detail63[] = $value52['score'];
				}
				$cha6 = array_sum($detail63);
				$fcount6 = count($score2);
				$fsum6 = $fcount6 * 90 + $cha6;
				$pfuz6 = round($fsum6 / $fcount6,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail62 as $key53 => $value53){
					$detail63[] = $value53['score'];
				}
				foreach($entry62 as $key53 => $value53){
					$entry63[] = $value53['score'];
				}
				$chaz621 = array_sum($detail63);
				$chaz622 = array_sum($entry63);
				$cha6 = $chaz621 + $chaz622;
				$fcount6 = count($score2);
				$fsum6 = $fcount6 * 90 + $cha6;
				$pfuz6 = round($fsum6 / $fcount6,2);
			}
		}
		// 六月 结束
		$yuan['5'] = $pyuan6;
		$xinz['5'] = $pxinz6;
		$fuz['5'] = $pfuz6;

		// 七月 开始
		for($i = 1;$i <= 7;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime14[] = $ktime1 . '-0' . $v;
			$ktime15[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where70['ktime'] = $ktime;
		$where70['mtime'] = array('in',$ktime15);
		$where70['score_id'] = array('in',$yuan_id);
		$where71['ktime'] = $ktime;
		$where71['mtime'] = array('in',$ktime14);
		$where71['score_id'] = array('in',$yuan_id);
		$detail7 = M('detail')->where($where70)->select();
		$entry7 = M('entry')->where($where71)->select();
		if(empty($detail7) && empty($entry7)){
			// 默认值
			$ycount7 = count($score0);
			$ysum7 = $ycount7 * 90;
			$pyuan7 = $ysum7 / $ycount7;
		}else{
			if(empty($detail7)){
				// 计算entry表中的数据
				foreach($entry7 as $key31 => $value31){
					$entry71[] = $value31['score'];
				}
				$cha7 = array_sum($entry71);
				$ycount7 = count($score0);
				$ysum7 = $ycount7 * 90 + $cha7;
				$pyuan7 = round($ysum7 / $ycount7,2);
			}elseif(empty($entry7)){
				// 计算detail表中的数据
				foreach($detail7 as $key32 => $value32){
					$detail71[] = $value32['score'];
				}
				$cha7 = array_sum($detail71);
				$ycount7 = count($score0);
				$ysum7 = $ycount7 * 90 + $cha7;
				$pyuan7 = round($ysum7 / $ycount7,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail7 as $key33 => $value33){
					$detail71[] = $value33['score'];
				}
				foreach($entry7 as $key33 => $value33){
					$entry71[] = $value33['score'];
				}
				$chaz711 = array_sum($detail71);
				$chaz712 = array_sum($entry71);
				$cha7 = $chaz711 + $chaz712;
				$ycount7 = count($score0);
				$ysum7 = $ycount7 * 90 + $cha7;
				$pyuan7 = round($ysum7 / $ycount7,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where72['ktime'] = $ktime;
		$where72['mtime'] = array('in',$ktime15);
		$where72['score_id'] = array('in',$xinz_id);
		$where73['ktime'] = $ktime;
		$where73['mtime'] = array('in',$ktime14);
		$where73['score_id'] = array('in',$xinz_id);
		$detail71 = M('detail')->where($where72)->select();
		$entry71 = M('entry')->where($where73)->select();
		if(empty($detail71) && empty($entry71)){
			// 默认值
			$xcount7 = count($score1);
			$xsum7 = $xcount7 * 90;
			$pxinz7 = $xsum7 / $xcount7;
		}else{
			if(empty($detail71)){
				// 计算entry表中的数据
				foreach($entry71 as $key41 => $value41){
					$entry72[] = $value41['score'];
				}
				$cha7 = array_sum($entry72);
				$xcount7 = count($score1);
				$xsum7 = $xcount7 * 90 + $cha7;
				$pxinz7 = round($xsum7 / $xcount7,2);
			}elseif(empty($entry71)){
				// 计算detail表中的数据
				foreach($detail71 as $key42 => $value42){
					$detail72[] = $value42['score'];
				}
				$cha7 = array_sum($detail72);
				$xcount7 = count($score1);
				$xsum7 = $xcount7 * 90 + $cha7;
				$pxinz7 = round($xsum7 / $xcount7,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail71 as $key43 => $value43){
					$detail72[] = $value43['score'];
				}
				foreach($entry71 as $key43 => $value43){
					$entry72[] = $value43['score'];
				}
				$chaz711 = array_sum($detail72);
				$chaz712 = array_sum($entry72);
				$cha7 = $chaz711 + $chaz712;
				$xcount7 = count($score1);
				$xsum7 = $xcount7 * 90 + $cha7;
				$pxinz7 = round($xsum7 / $xcount7,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where74['ktime'] = $ktime;
		$where74['mtime'] = array('in',$ktime15);
		$where74['score_id'] = array('in',$fuz_id);
		$where75['ktime'] = $ktime;
		$where75['mtime'] = array('in',$ktime14);
		$where75['score_id'] = array('in',$fuz_id);
		$detail72 = M('detail')->where($where74)->select();
		$entry72 = M('entry')->where($where75)->select();
		if(empty($detail72) && empty($entry72)){
			// 默认值
			$fcount7 = count($score2);
			$fsum7 = $fcount7 * 90;
			$pfuz7 = $fsum7 / $fcount7;
		}else{
			if(empty($detail72)){
				// 计算entry表中的数据
				foreach($entry72 as $key51 => $value51){
					$entry73[] = $value51['score'];
				}
				$cha7 = array_sum($entry73);
				$fcount7 = count($score2);
				$fsum7 = $fcount7 * 90 + $cha7;
				$pfuz7 = round($fsum7 / $fcount7,2);
			}elseif(empty($entry72)){
				// 计算detail表中的数据
				foreach($detail72 as $key52 => $value52){
					$detail73[] = $value52['score'];
				}
				$cha7 = array_sum($detail73);
				$fcount7 = count($score2);
				$fsum7 = $fcount7 * 90 + $cha7;
				$pfuz7 = round($fsum7 / $fcount7,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail72 as $key53 => $value53){
					$detail73[] = $value53['score'];
				}
				foreach($entry72 as $key53 => $value53){
					$entry73[] = $value53['score'];
				}
				$chaz721 = array_sum($detail73);
				$chaz722 = array_sum($entry73);
				$cha7 = $chaz721 + $chaz722;
				$fcount7 = count($score2);
				$fsum7 = $fcount7 * 90 + $cha7;
				$pfuz7 = round($fsum7 / $fcount7,2);
			}
		}
		// 七月 结束
		$yuan['6'] = $pyuan7;
		$xinz['6'] = $pxinz7;
		$fuz['6'] = $pfuz7;

		// 八月 开始
		for($i = 1;$i <= 8;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime16[] = $ktime1 . '-0' . $v;
			$ktime17[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where80['ktime'] = $ktime;
		$where80['mtime'] = array('in',$ktime17);
		$where80['score_id'] = array('in',$yuan_id);
		$where81['ktime'] = $ktime;
		$where81['mtime'] = array('in',$ktime16);
		$where81['score_id'] = array('in',$yuan_id);
		$detail8 = M('detail')->where($where80)->select();
		$entry8 = M('entry')->where($where81)->select();
		if(empty($detail8) && empty($entry8)){
			// 默认值
			$ycount8 = count($score0);
			$ysum8 = $ycount8 * 90;
			$pyuan8 = $ysum8 / $ycount8;
		}else{
			if(empty($detail8)){
				// 计算entry表中的数据
				foreach($entry8 as $key31 => $value31){
					$entry81[] = $value31['score'];
				}
				$cha8 = array_sum($entry81);
				$ycount8 = count($score0);
				$ysum8 = $ycount8 * 90 + $cha8;
				$pyuan8 = round($ysum8 / $ycount8,2);
			}elseif(empty($entry8)){
				// 计算detail表中的数据
				foreach($detail8 as $key32 => $value32){
					$detail81[] = $value32['score'];
				}
				$cha8 = array_sum($detail81);
				$ycount8 = count($score0);
				$ysum8 = $ycount8 * 90 + $cha8;
				$pyuan8 = round($ysum8 / $ycount8,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail8 as $key33 => $value33){
					$detail81[] = $value33['score'];
				}
				foreach($entry8 as $key33 => $value33){
					$entry81[] = $value33['score'];
				}
				$chaz811 = array_sum($detail81);
				$chaz812 = array_sum($entry81);
				$cha8 = $chaz811 + $chaz812;
				$ycount8 = count($score0);
				$ysum8 = $ycount8 * 90 + $cha8;
				$pyuan8 = round($ysum8 / $ycount8,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where82['ktime'] = $ktime;
		$where82['mtime'] = array('in',$ktime17);
		$where82['score_id'] = array('in',$xinz_id);
		$where83['ktime'] = $ktime;
		$where83['mtime'] = array('in',$ktime16);
		$where83['score_id'] = array('in',$xinz_id);
		$detail81 = M('detail')->where($where82)->select();
		$entry81 = M('entry')->where($where83)->select();
		if(empty($detail81) && empty($entry81)){
			// 默认值
			$xcount8 = count($score1);
			$xsum8 = $xcount8 * 90;
			$pxinz8 = $xsum8 / $xcount8;
		}else{
			if(empty($detail81)){
				// 计算entry表中的数据
				foreach($entry81 as $key41 => $value41){
					$entry82[] = $value41['score'];
				}
				$cha8 = array_sum($entry82);
				$xcount8 = count($score1);
				$xsum8 = $xcount8 * 90 + $cha8;
				$pxinz8 = round($xsum8 / $xcount8,2);
			}elseif(empty($entry81)){
				// 计算detail表中的数据
				foreach($detail81 as $key42 => $value42){
					$detail82[] = $value42['score'];
				}
				$cha8 = array_sum($detail82);
				$xcount8 = count($score1);
				$xsum8 = $xcount8 * 90 + $cha8;
				$pxinz8 = round($xsum8 / $xcount8,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail81 as $key43 => $value43){
					$detail82[] = $value43['score'];
				}
				foreach($entry81 as $key43 => $value43){
					$entry82[] = $value43['score'];
				}
				$chaz811 = array_sum($detail82);
				$chaz812 = array_sum($entry82);
				$cha8 = $chaz811 + $chaz812;
				$xcount8 = count($score1);
				$xsum8 = $xcount8 * 90 + $cha8;
				$pxinz8 = round($xsum8 / $xcount8,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where84['ktime'] = $ktime;
		$where84['mtime'] = array('in',$ktime17);
		$where84['score_id'] = array('in',$fuz_id);
		$where85['ktime'] = $ktime;
		$where85['mtime'] = array('in',$ktime16);
		$where85['score_id'] = array('in',$fuz_id);
		$detail82 = M('detail')->where($where84)->select();
		$entry82 = M('entry')->where($where85)->select();
		if(empty($detail82) && empty($entry82)){
			// 默认值
			$fcount8 = count($score2);
			$fsum8 = $fcount8 * 90;
			$pfuz8 = $fsum8 / $fcount8;
		}else{
			if(empty($detail82)){
				// 计算entry表中的数据
				foreach($entry82 as $key51 => $value51){
					$entry83[] = $value51['score'];
				}
				$cha8 = array_sum($entry83);
				$fcount8 = count($score2);
				$fsum8 = $fcount8 * 90 + $cha8;
				$pfuz8 = round($fsum8 / $fcount8,2);
			}elseif(empty($entry82)){
				// 计算detail表中的数据
				foreach($detail82 as $key52 => $value52){
					$detail83[] = $value52['score'];
				}
				$cha8 = array_sum($detail83);
				$fcount8 = count($score2);
				$fsum8 = $fcount8 * 90 + $cha8;
				$pfuz8 = round($fsum8 / $fcount8,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail82 as $key53 => $value53){
					$detail83[] = $value53['score'];
				}
				foreach($entry82 as $key53 => $value53){
					$entry83[] = $value53['score'];
				}
				$chaz821 = array_sum($detail83);
				$chaz822 = array_sum($entry83);
				$cha8 = $chaz821 + $chaz822;
				$fcount8 = count($score2);
				$fsum8 = $fcount8 * 90 + $cha8;
				$pfuz8 = round($fsum8 / $fcount8,2);
			}
		}
		// 八月 结束
		$yuan['7'] = $pyuan8;
		$xinz['7'] = $pxinz8;
		$fuz['7'] = $pfuz8;

		// 九月 开始
		for($i = 1;$i <= 9;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime18[] = $ktime1 . '-0' . $v;
			$ktime19[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where90['ktime'] = $ktime;
		$where90['mtime'] = array('in',$ktime19);
		$where90['score_id'] = array('in',$yuan_id);
		$where91['ktime'] = $ktime;
		$where91['mtime'] = array('in',$ktime18);
		$where91['score_id'] = array('in',$yuan_id);
		$detail9 = M('detail')->where($where90)->select();
		$entry9 = M('entry')->where($where91)->select();
		if(empty($detail9) && empty($entry9)){
			// 默认值
			$ycount9 = count($score0);
			$ysum9 = $ycount9 * 90;
			$pyuan9 = $ysum9 / $ycount9;
		}else{
			if(empty($detail9)){
				// 计算entry表中的数据
				foreach($entry9 as $key31 => $value31){
					$entry91[] = $value31['score'];
				}
				$cha9 = array_sum($entry91);
				$ycount9 = count($score0);
				$ysum9 = $ycount9 * 90 + $cha9;
				$pyuan9 = round($ysum9 / $ycount9,2);
			}elseif(empty($entry9)){
				// 计算detail表中的数据
				foreach($detail9 as $key32 => $value32){
					$detail91[] = $value32['score'];
				}
				$cha9 = array_sum($detail91);
				$ycount9 = count($score0);
				$ysum9 = $ycount9 * 90 + $cha9;
				$pyuan9 = round($ysum9 / $ycount9,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail9 as $key33 => $value33){
					$detail91[] = $value33['score'];
				}
				foreach($entry9 as $key33 => $value33){
					$entry91[] = $value33['score'];
				}
				$chaz911 = array_sum($detail91);
				$chaz912 = array_sum($entry91);
				$cha9 = $chaz911 + $chaz912;
				$ycount9 = count($score0);
				$ysum9 = $ycount9 * 90 + $cha9;
				$pyuan9 = round($ysum9 / $ycount9,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where92['ktime'] = $ktime;
		$where92['mtime'] = array('in',$ktime19);
		$where92['score_id'] = array('in',$xinz_id);
		$where93['ktime'] = $ktime;
		$where93['mtime'] = array('in',$ktime18);
		$where93['score_id'] = array('in',$xinz_id);
		$detail91 = M('detail')->where($where92)->select();
		$entry91 = M('entry')->where($where93)->select();
		if(empty($detail91) && empty($entry91)){
			// 默认值
			$xcount9 = count($score1);
			$xsum9 = $xcount9 * 90;
			$pxinz9 = $xsum9 / $xcount9;
		}else{
			if(empty($detail91)){
				// 计算entry表中的数据
				foreach($entry91 as $key41 => $value41){
					$entry92[] = $value41['score'];
				}
				$cha9 = array_sum($entry92);
				$xcount9 = count($score1);
				$xsum9 = $xcount9 * 90 + $cha9;
				$pxinz9 = round($xsum9 / $xcount9,2);
			}elseif(empty($entry91)){
				// 计算detail表中的数据
				foreach($detail91 as $key42 => $value42){
					$detail92[] = $value42['score'];
				}
				$cha9 = array_sum($detail92);
				$xcount9 = count($score1);
				$xsum9 = $xcount9 * 90 + $cha9;
				$pxinz9 = round($xsum9 / $xcount9,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail91 as $key43 => $value43){
					$detail92[] = $value43['score'];
				}
				foreach($entry91 as $key43 => $value43){
					$entry92[] = $value43['score'];
				}
				$chaz911 = array_sum($detail92);
				$chaz912 = array_sum($entry92);
				$cha9 = $chaz911 + $chaz912;
				$xcount9 = count($score1);
				$xsum9 = $xcount9 * 90 + $cha9;
				$pxinz9 = round($xsum9 / $xcount9,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where94['ktime'] = $ktime;
		$where94['mtime'] = array('in',$ktime19);
		$where94['score_id'] = array('in',$fuz_id);
		$where95['ktime'] = $ktime;
		$where95['mtime'] = array('in',$ktime18);
		$where95['score_id'] = array('in',$fuz_id);
		$detail92 = M('detail')->where($where94)->select();
		$entry92 = M('entry')->where($where95)->select();
		if(empty($detail92) && empty($entry92)){
			// 默认值
			$fcount9 = count($score2);
			$fsum9 = $fcount9 * 90;
			$pfuz9 = $fsum9 / $fcount9;
		}else{
			if(empty($detail92)){
				// 计算entry表中的数据
				foreach($entry92 as $key51 => $value51){
					$entry93[] = $value51['score'];
				}
				$cha9 = array_sum($entry93);
				$fcount9 = count($score2);
				$fsum9 = $fcount9 * 90 + $cha9;
				$pfuz9 = round($fsum9 / $fcount9,2);
			}elseif(empty($entry92)){
				// 计算detail表中的数据
				foreach($detail92 as $key52 => $value52){
					$detail93[] = $value52['score'];
				}
				$cha9 = array_sum($detail93);
				$fcount9 = count($score2);
				$fsum9 = $fcount9 * 90 + $cha9;
				$pfuz9 = round($fsum9 / $fcount9,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail92 as $key53 => $value53){
					$detail93[] = $value53['score'];
				}
				foreach($entry92 as $key53 => $value53){
					$entry93[] = $value53['score'];
				}
				$chaz921 = array_sum($detail93);
				$chaz922 = array_sum($entry93);
				$cha9 = $chaz921 + $chaz922;
				$fcount9 = count($score2);
				$fsum9 = $fcount9 * 90 + $cha9;
				$pfuz9 = round($fsum9 / $fcount9,2);
			}
		}
		// 九月 结束
		$yuan['8'] = $pyuan9;
		$xinz['8'] = $pxinz9;
		$fuz['8'] = $pfuz9;

		// 十月 开始
		for($i = 1;$i <= 10;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime20[] = $ktime1 . '-' . $v;
			$ktime21[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where100['ktime'] = $ktime;
		$where100['mtime'] = array('in',$ktime21);
		$where100['score_id'] = array('in',$yuan_id);
		$where101['ktime'] = $ktime;
		$where101['mtime'] = array('in',$ktime20);
		$where101['score_id'] = array('in',$yuan_id);
		$detail10 = M('detail')->where($where100)->select();
		$entry10 = M('entry')->where($where101)->select();
		if(empty($detail10) && empty($entry10)){
			// 默认值
			$ycount10 = count($score0);
			$ysum10 = $ycount10 * 90;
			$pyuan10 = $ysum10 / $ycount10;
		}else{
			if(empty($detail10)){
				// 计算entry表中的数据
				foreach($entry10 as $key31 => $value31){
					$entry101[] = $value31['score'];
				}
				$cha10 = array_sum($entry101);
				$ycount10 = count($score0);
				$ysum10 = $ycount10 * 90 + $cha10;
				$pyuan10 = round($ysum10 / $ycount10,2);
			}elseif(empty($entry10)){
				// 计算detail表中的数据
				foreach($detail10 as $key32 => $value32){
					$detail101[] = $value32['score'];
				}
				$cha10 = array_sum($detail101);
				$ycount10 = count($score0);
				$ysum10 = $ycount10 * 90 + $cha10;
				$pyuan10 = round($ysum10 / $ycount10,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail10 as $key33 => $value33){
					$detail101[] = $value33['score'];
				}
				foreach($entry10 as $key33 => $value33){
					$entry101[] = $value33['score'];
				}
				$chaz1011 = array_sum($detail101);
				$chaz1012 = array_sum($entry101);
				$cha10 = $chaz1011 + $chaz1012;
				$ycount10 = count($score0);
				$ysum10 = $ycount10 * 90 + $cha10;
				$pyuan10 = round($ysum10 / $ycount10,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where102['ktime'] = $ktime;
		$where102['mtime'] = array('in',$ktime21);
		$where102['score_id'] = array('in',$xinz_id);
		$where103['ktime'] = $ktime;
		$where103['mtime'] = array('in',$ktime20);
		$where103['score_id'] = array('in',$xinz_id);
		$detail101 = M('detail')->where($where102)->select();
		$entry101 = M('entry')->where($where103)->select();
		if(empty($detail101) && empty($entry101)){
			// 默认值
			$xcount10 = count($score1);
			$xsum10 = $xcount10 * 90;
			$pxinz10 = $xsum10 / $xcount10;
		}else{
			if(empty($detail101)){
				// 计算entry表中的数据
				foreach($entry101 as $key41 => $value41){
					$entry102[] = $value41['score'];
				}
				$cha10 = array_sum($entry102);
				$xcount10 = count($score1);
				$xsum10 = $xcount10 * 90 + $cha10;
				$pxinz10 = round($xsum10 / $xcount10,2);
			}elseif(empty($entry101)){
				// 计算detail表中的数据
				foreach($detail101 as $key42 => $value42){
					$detail102[] = $value42['score'];
				}
				$cha10 = array_sum($detail102);
				$xcount10 = count($score1);
				$xsum10 = $xcount10 * 90 + $cha10;
				$pxinz10 = round($xsum10 / $xcount10,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail101 as $key43 => $value43){
					$detail102[] = $value43['score'];
				}
				foreach($entry31 as $key43 => $value43){
					$entry102[] = $value43['score'];
				}
				$chaz1011 = array_sum($detail102);
				$chaz1012 = array_sum($entry102);
				$cha10 = $chaz1011 + $chaz1012;
				$xcount10 = count($score1);
				$xsum10 = $xcount10 * 90 + $cha10;
				$pxinz10 = round($xsum10 / $xcount10,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where104['ktime'] = $ktime;
		$where104['mtime'] = array('in',$ktime21);
		$where104['score_id'] = array('in',$fuz_id);
		$where105['ktime'] = $ktime;
		$where105['mtime'] = array('in',$ktime20);
		$where105['score_id'] = array('in',$fuz_id);
		$detail102 = M('detail')->where($where104)->select();
		$entry102 = M('entry')->where($where105)->select();
		if(empty($detail102) && empty($entry102)){
			// 默认值
			$fcount10 = count($score2);
			$fsum10 = $fcount10 * 90;
			$pfuz10 = $fsum10 / $fcount10;
		}else{
			if(empty($detail102)){
				// 计算entry表中的数据
				foreach($entry102 as $key51 => $value51){
					$entry103[] = $value51['score'];
				}
				$cha10 = array_sum($entry103);
				$fcount10 = count($score2);
				$fsum10 = $fcount10 * 90 + $cha10;
				$pfuz10 = round($fsum10 / $fcount10,2);
			}elseif(empty($entry102)){
				// 计算detail表中的数据
				foreach($detail102 as $key52 => $value52){
					$detail103[] = $value52['score'];
				}
				$cha10 = array_sum($detail103);
				$fcount10 = count($score2);
				$fsum10 = $fcount10 * 90 + $cha10;
				$pfuz10 = round($fsum10 / $fcount10,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail102 as $key53 => $value53){
					$detail103[] = $value53['score'];
				}
				foreach($entry102 as $key53 => $value53){
					$entry103[] = $value53['score'];
				}
				$chaz1021 = array_sum($detail103);
				$chaz1022 = array_sum($entry103);
				$cha10 = $chaz1021 + $chaz1022;
				$fcount10 = count($score2);
				$fsum10 = $fcount10 * 90 + $cha10;
				$pfuz10 = round($fsum10 / $fcount10,2);
			}
		}
		// 十月 结束
		$yuan['9'] = $pyuan10;
		$xinz['9'] = $pxinz10;
		$fuz['9'] = $pfuz10;

		// 十一月 开始
		for($i = 1;$i <= 11;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime22[] = $ktime1 . '-0' . $v;
			$ktime23[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where110['ktime'] = $ktime;
		$where110['mtime'] = array('in',$ktime23);
		$where110['score_id'] = array('in',$yuan_id);
		$where111['ktime'] = $ktime;
		$where111['mtime'] = array('in',$ktime22);
		$where111['score_id'] = array('in',$yuan_id);
		$detail11 = M('detail')->where($where110)->select();
		$entry11 = M('entry')->where($where111)->select();
		if(empty($detail11) && empty($entry11)){
			// 默认值
			$ycount11 = count($score0);
			$ysum11 = $ycount11 * 90;
			$pyuan11 = $ysum11 / $ycount11;
		}else{
			if(empty($detail11)){
				// 计算entry表中的数据
				foreach($entry11 as $key31 => $value31){
					$entry111[] = $value31['score'];
				}
				$cha11 = array_sum($entry111);
				$ycount11 = count($score0);
				$ysum11 = $ycount11 * 90 + $cha11;
				$pyuan11 = round($ysum11 / $ycount11,2);
			}elseif(empty($entry11)){
				// 计算detail表中的数据
				foreach($detail11 as $key32 => $value32){
					$detail111[] = $value32['score'];
				}
				$cha11 = array_sum($detail111);
				$ycount11 = count($score0);
				$ysum11 = $ycount11 * 90 + $cha11;
				$pyuan11 = round($ysum11 / $ycount11,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail11 as $key33 => $value33){
					$detail111[] = $value33['score'];
				}
				foreach($entry11 as $key33 => $value33){
					$entry111[] = $value33['score'];
				}
				$chaz1111 = array_sum($detail111);
				$chaz1112 = array_sum($entry111);
				$cha11 = $chaz1111 + $chaz1112;
				$ycount11 = count($score0);
				$ysum11 = $ycount11 * 90 + $cha11;
				$pyuan11 = round($ysum11 / $ycount11,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where112['ktime'] = $ktime;
		$where112['mtime'] = array('in',$ktime23);
		$where112['score_id'] = array('in',$xinz_id);
		$where113['ktime'] = $ktime;
		$where113['mtime'] = array('in',$ktime22);
		$where113['score_id'] = array('in',$xinz_id);
		$detail111 = M('detail')->where($where112)->select();
		$entry111 = M('entry')->where($where113)->select();
		if(empty($detail111) && empty($entry111)){
			// 默认值
			$xcount11 = count($score1);
			$xsum11 = $xcount11 * 90;
			$pxinz11 = $xsum11 / $xcount11;
		}else{
			if(empty($detail111)){
				// 计算entry表中的数据
				foreach($entry111 as $key41 => $value41){
					$entry112[] = $value41['score'];
				}
				$cha11 = array_sum($entry112);
				$xcount11 = count($score1);
				$xsum11 = $xcount11 * 90 + $cha11;
				$pxinz11 = round($xsum11 / $xcount11,2);
			}elseif(empty($entry111)){
				// 计算detail表中的数据
				foreach($detail111 as $key42 => $value42){
					$detail112[] = $value42['score'];
				}
				$cha11 = array_sum($detail112);
				$xcount11 = count($score1);
				$xsum11 = $xcount11 * 90 + $cha11;
				$pxinz11 = round($xsum11 / $xcount11,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail111 as $key43 => $value43){
					$detail112[] = $value43['score'];
				}
				foreach($entry111 as $key43 => $value43){
					$entry112[] = $value43['score'];
				}
				$chaz1111 = array_sum($detail112);
				$chaz1112 = array_sum($entry112);
				$cha11 = $chaz1111 + $chaz1112;
				$xcount11 = count($score1);
				$xsum11 = $xcount11 * 90 + $cha11;
				$pxinz11 = round($xsum11 / $xcount11,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where114['ktime'] = $ktime;
		$where114['mtime'] = array('in',$ktime23);
		$where114['score_id'] = array('in',$fuz_id);
		$where115['ktime'] = $ktime;
		$where115['mtime'] = array('in',$ktime22);
		$where115['score_id'] = array('in',$fuz_id);
		$detail112 = M('detail')->where($where114)->select();
		$entry112 = M('entry')->where($where115)->select();
		if(empty($detail112) && empty($entry112)){
			// 默认值
			$fcount11 = count($score2);
			$fsum11 = $fcount11 * 90;
			$pfuz11 = $fsum11 / $fcount11;
		}else{
			if(empty($detail112)){
				// 计算entry表中的数据
				foreach($entry112 as $key51 => $value51){
					$entry113[] = $value51['score'];
				}
				$cha11 = array_sum($entry113);
				$fcount11 = count($score2);
				$fsum11 = $fcount11 * 90 + $cha11;
				$pfuz11 = round($fsum11 / $fcount11,2);
			}elseif(empty($entry112)){
				// 计算detail表中的数据
				foreach($detail112 as $key52 => $value52){
					$detail113[] = $value52['score'];
				}
				$cha11 = array_sum($detail113);
				$fcount11 = count($score2);
				$fsum11 = $fcount11 * 90 + $cha11;
				$pfuz11 = round($fsum11 / $fcount11,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail112 as $key53 => $value53){
					$detail113[] = $value53['score'];
				}
				foreach($entry112 as $key53 => $value53){
					$entry113[] = $value53['score'];
				}
				$chaz1121 = array_sum($detail113);
				$chaz1122 = array_sum($entry113);
				$cha11 = $chaz1121 + $chaz1122;
				$fcount11 = count($score2);
				$fsum11 = $fcount11 * 90 + $cha11;
				$pfuz11 = round($fsum11 / $fcount11,2);
			}
		}
		// 十一月 结束
		$yuan['10'] = $pyuan11;
		$xinz['10'] = $pxinz11;
		$fuz['10'] = $pfuz11;

		// 十二月 开始
		for($i = 1;$i <= 12;$i++){
			$a[] = $i;
		}
		$a = array_unique($a);
		foreach($a as $k => $v){
			$ktime24[] = $ktime1 . '-0' . $v;
			$ktime25[] = strtotime($ktime1 . '-' . $v);
		}
		// 员额法官
		foreach($score0 as $key3 => $value3){
			$yuan_id[] = $value3['id'];
		}
		$where120['ktime'] = $ktime;
		$where120['mtime'] = array('in',$ktime25);
		$where120['score_id'] = array('in',$yuan_id);
		$where121['ktime'] = $ktime;
		$where121['mtime'] = array('in',$ktime24);
		$where121['score_id'] = array('in',$yuan_id);
		$detail12 = M('detail')->where($where120)->select();
		$entry12 = M('entry')->where($where121)->select();
		if(empty($detail12) && empty($entry12)){
			// 默认值
			$ycount12 = count($score0);
			$ysum12 = $ycount12 * 90;
			$pyuan12 = $ysum12 / $ycount12;
		}else{
			if(empty($detail12)){
				// 计算entry表中的数据
				foreach($entry12 as $key31 => $value31){
					$entry121[] = $value31['score'];
				}
				$cha12 = array_sum($entry121);
				$ycount12 = count($score0);
				$ysum12 = $ycount12 * 90 + $cha12;
				$pyuan12 = round($ysum12 / $ycount12,2);
			}elseif(empty($entry12)){
				// 计算detail表中的数据
				foreach($detail12 as $key32 => $value32){
					$detail121[] = $value32['score'];
				}
				$cha12 = array_sum($detail121);
				$ycount12 = count($score0);
				$ysum12 = $ycount12 * 90 + $cha12;
				$pyuan12 = round($ysum12 / $ycount12,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail12 as $key33 => $value33){
					$detail121[] = $value33['score'];
				}
				foreach($entry12 as $key33 => $value33){
					$entry121[] = $value33['score'];
				}
				$chaz1211 = array_sum($detail121);
				$chaz1212 = array_sum($entry121);
				$cha12 = $chaz1211 + $chaz1212;
				$ycount12 = count($score0);
				$ysum12 = $ycount12 * 90 + $cha12;
				$pyuan12 = round($ysum12 / $ycount12,2);
			}
		}
		// 司法行政人员
		foreach($score1 as $key4 => $value4){
			$xinz_id[] = $value4['id'];
		}
		$where122['ktime'] = $ktime;
		$where122['mtime'] = array('in',$ktime25);
		$where122['score_id'] = array('in',$xinz_id);
		$where123['ktime'] = $ktime;
		$where123['mtime'] = array('in',$ktime24);
		$where123['score_id'] = array('in',$xinz_id);
		$detail121 = M('detail')->where($where122)->select();
		$entry121 = M('entry')->where($where123)->select();
		if(empty($detail121) && empty($entry121)){
			// 默认值
			$xcount12 = count($score1);
			$xsum12 = $xcount12 * 90;
			$pxinz12 = $xsum12 / $xcount12;
		}else{
			if(empty($detail121)){
				// 计算entry表中的数据
				foreach($entry121 as $key41 => $value41){
					$entry122[] = $value41['score'];
				}
				$cha12 = array_sum($entry122);
				$xcount12 = count($score1);
				$xsum12 = $xcount12 * 90 + $cha12;
				$pxinz12 = round(12 / $xcount12,2);
			}elseif(empty($entry121)){
				// 计算detail表中的数据
				foreach($detail121 as $key42 => $value42){
					$detail122[] = $value42['score'];
				}
				$cha12 = array_sum($detail122);
				$xcount12 = count($score1);
				$xsum12 = $xcount12 * 90 + $cha12;
				$pxinz12 = round($xsum12 / $xcount12,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail121 as $key43 => $value43){
					$detail122[] = $value43['score'];
				}
				foreach($entry121 as $key43 => $value43){
					$entry122[] = $value43['score'];
				}
				$chaz1211 = array_sum($detail122);
				$chaz1212 = array_sum($entry122);
				$cha12 = $chaz1211 + $chaz1212;
				$xcount12 = count($score1);
				$xsum12 = $xcount12 * 90 + $cha12;
				$pxinz12 = round($xsum12 / $xcount12,2);
			}
		}
		// 司法辅助人员
		foreach($score2 as $key5 => $value5){
			$fuz_id[] = $value5['id'];
		}
		$where124['ktime'] = $ktime;
		$where124['mtime'] = array('in',$ktime25);
		$where124['score_id'] = array('in',$fuz_id);
		$where125['ktime'] = $ktime;
		$where125['mtime'] = array('in',$ktime24);
		$where125['score_id'] = array('in',$fuz_id);
		$detail122 = M('detail')->where($where124)->select();
		$entry122 = M('entry')->where($where125)->select();
		if(empty($detail122) && empty($entry122)){
			// 默认值
			$fcount12 = count($score2);
			$fsum12 = $fcount12 * 90;
			$pfuz12 = $fsum12 / $fcount12;
		}else{
			if(empty($detail122)){
				// 计算entry表中的数据
				foreach($entry122 as $key51 => $value51){
					$entry123[] = $value51['score'];
				}
				$cha12 = array_sum($entry123);
				$fcount12 = count($score2);
				$fsum12 = $fcount12 * 90 + $cha12;
				$pfuz12 = round($fsum12 / $fcount12,2);
			}elseif(empty($entry122)){
				// 计算detail表中的数据
				foreach($detail122 as $key52 => $value52){
					$detail123[] = $value52['score'];
				}
				$cha12 = array_sum($detail123);
				$fcount12 = count($score2);
				$fsum12 = $fcount12 * 90 + $cha12;
				$pfuz12 = round($fsum12 / $fcount12,2);
			}else{
				// 计算detail表和entry表中的数据和
				foreach($detail122 as $key53 => $value53){
					$detail123[] = $value53['score'];
				}
				foreach($entry122 as $key53 => $value53){
					$entry123[] = $value53['score'];
				}
				$chaz1221 = array_sum($detail123);
				$chaz1222 = array_sum($entry123);
				$cha12 = $chaz1221 + $chaz1222;
				$fcount12 = count($score2);
				$fsum12 = $fcount12 * 90 + $cha12;
				$pfuz12 = round($fsum12 / $fcount12,2);
			}
		}
		// 十二月 结束
		$yuan['11'] = $pyuan12;
		$xinz['11'] = $pxinz12;
		$fuz['11'] = $pfuz12;
		$yuane = implode(',',$yuan);
		$xinz = implode(',',$xinz);
		$fuz = implode(',',$fuz);
		$this->assign('yuane',$yuane);
		$this->assign('xinz',$xinz);
		$this->assign('fuz',$fuz);
		$this->display();
	}

	// 第三个图 人员分类下拉框ajax请求
	public function three(){
		// var_dump($_POST);die;
		$notes_id = $_POST['id'];
		$posts_id = $_POST['posts_id'];
		$notes = M('notes')->where('id='.$notes_id)->find();
		$ktime = $notes['ktime'];
		$ktime1 = date('Y',$ktime);
		$posts = M('posts')->where('posts_id='.$posts_id)->find();
		$posts0 = M('posts')->where('parent_id='.$posts_id)->select();
		foreach($posts0 as $k0 => $v0){
			$posts00[] = $v0['posts_id'];
		}
		$map0['posts_id'] = array('in',$posts00);
		$map0['test_time'] = $ktime;
		$score0 = M('score')->where($map0)->select();
		// var_dump($score0);die;
		$count0 = count($score0); // 所选人员类别的人数
		$mp0['ktime'] = $ktime1;
		$mp0['posts'] = $posts_id;
		$class0 = M('class')->where($mp0)->order('class_id asc')->select();
		foreach($score0 as $key0 => $val0){
			if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
				$sum01[] = $val0['sum'];
				$count01 = count($sum01);
				$bfb = $count01 / $count0 * '100%';
				$bfb01 = round($bfb,2);
			}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
				$sum02[] = $val0['sum'];
				$count02 = count($sum02);
				$bfb = $count02 / $count0 * '100%';
				$bfb02 = round($bfb,2);
			}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
				$sum03[] = $val0['sum'];
				$count03 = count($sum03);
				$bfb = $count03 / $count0 * '100%';
				$bfb03 = round($bfb,2);
			}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
				$sum04[] = $val0['sum'];
				$count04 = count($sum04);
				$bfb = $count04 / $count0 * '100%';
				$bfb04 = round($bfb,2);
			}
		}
		if(empty($bfb01)){
			$bfb01 = 0;
		}
		if(empty($bfb02)){
			$bfb02 = 0;
		}
		if(empty($bfb03)){
			$bfb03 = 0;
		}
		if(empty($bfb04)){
			$bfb04 = 0;
		}
		$three['0'] = $bfb01;
		$three['1'] = $bfb02;
		$three['2'] = $bfb03;
		$three['3'] = $bfb04;
		$three = implode(',',$three);
		// var_dump($three);die;
		foreach($score0 as $k3 => $v3){
			$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
			foreach($worker as $k4 => $v4){
				$lei[$k3]['worker_name'] = $v4['worker_name'];
			}
			$lei[$k3]['sum'] = $v3['sum'];
		}
		// 排序
		$sums = array();
		foreach($lei as $li){
			$sums[] = $li['sum'];
		}
		array_multisort($sums,SORT_DESC,$lei);
		$lname1 = 0;
        $lsum1 = 0;
		$b = count($lei);
		for($i=0;$i<$b;$i++){
			$lname1 .= $lei[$i]['worker_name'] . ',';
			$lsum1 .= $lei[$i]['sum'] . ',';
		}
		$lname1 = substr($lname1,1);
		$lsum1 = substr($lsum1,1);
		$lname = rtrim($lname1,',');
		$lsum = rtrim($lsum1,',');
		// var_dump($lname);
		// var_dump($lsum);die;
		$this->assign('posts',$posts['posts_name']);
		$this->assign('three',$three);
		$this->assign('lname',$lname);
		$this->assign('lsum',$lsum);
		$this->display();
	}

	// 第三个图 季度选择下拉框ajax请求
	public function three1(){
		// var_dump($_POST);die;
		$id = $_POST['id']; // 考核表id
		$quarter = $_POST['quarter']; // 季度
		$posts_id = $_POST['posts_id']; // 岗位id
		$posts = M('posts')->where('posts_id='.$posts_id)->find();
		$notes = M('notes')->where('id='.$id)->find();
		$year = date("Y",$notes['ktime']);
		$cposts = M('posts')->where('parent_id='.$posts_id)->select();
		foreach($cposts as $k1 => $v1){
			$cpos[] = $v1['posts_id'];
		}
		$mp1['posts_id'] = array('in',$cpos);
		$mp1['test_time'] = $notes['ktime'];
		$score = M('score')->where($mp1)->select();
		$count = count($score);
		foreach($score as $k2 => $v2){
			$score_ids[] = $v2['id'];
		}
		if($quarter == '1'){
			for($i = 1;$i <= 3;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year .'-'.$v);
				$ctime2[] = $year . '-0' . $v;
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$score_ids);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$score_ids);
			$map2['ktime'] = $notes['ktime'];
			$detail = M('detail')->where($map1)->select();
			$entry = M('entry')->where($map2)->select();
		}elseif($quarter == '2'){
			for($i = 1;$i <= 6;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year .'-'.$v);
				$ctime2[] = $year . '-0' . $v;
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$score_ids);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$score_ids);
			$map2['ktime'] = $notes['ktime'];
		}elseif($quarter == '3'){
			for($i = 1;$i <= 9;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year .'-'.$v);
				$ctime2[] = $year . '-0' . $v;
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$score_ids);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$score_ids);
			$map2['ktime'] = $notes['ktime'];
		}elseif($quarter == '4'){
			for($i = 1;$i <= 12;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year .'-'.$v);
				if($v == 10){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
				}elseif($v == 11){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
					$ctime2['10'] = $year . '-' . '11';
				}elseif($v == 12){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
					$ctime2['10'] = $year . '-' . '11';
					$ctime2['11'] = $year . '-' . '12';
				}else{
					$ctime2[] = $year . '-0' . $v;
				}
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$score_ids);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$score_ids);
			$map2['ktime'] = $notes['ktime'];
		}
		$detail = M('detail')->where($map1)->select();
		$entry = M('entry')->where($map2)->select();
		// var_dump($detail);
		// var_dump($entry);die;
		if(empty($detail) && empty($entry)){
			// 默认值
			// var_dump($score);die;
			$mp['ktime'] = $year;
			$mp['posts'] = $posts_id;
			$class0 = M('class')->where($mp)->order('class_id asc')->select();
			foreach($score as $k => $v){
				$score[$k]['sum'] = 90;
			}
			foreach($score as $key0 => $val0){
				if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
					$sum01[] = $val0['sum'];
					$count01 = count($sum01);
					$bfb = $count01 / $count * '100%';
					$bfb01 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
					$sum02[] = $val0['sum'];
					$count02 = count($sum02);
					$bfb = $count02 / $count * '100%';
					$bfb02 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
					$sum03[] = $val0['sum'];
					$count03 = count($sum03);
					$bfb = $count03 / $count * '100%';
					$bfb03 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
					$sum04[] = $val0['sum'];
					$count04 = count($sum04);
					$bfb = $count04 / $count * '100%';
					$bfb04 = round($bfb,2);
				}
			}
			if(empty($bfb01)){
				$bfb01 = 0;
			}
			if(empty($bfb02)){
				$bfb02 = 0;
			}
			if(empty($bfb03)){
				$bfb03 = 0;
			}
			if(empty($bfb04)){
				$bfb04 = 0;
			}
			$three1['0'] = $bfb01;
			$three1['1'] = $bfb02;
			$three1['2'] = $bfb03;
			$three1['3'] = $bfb04;
			$three1 = implode(',',$three1);
			// var_dump($three);die;
			foreach($score as $k3 => $v3){
				$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
				foreach($worker as $k4 => $v4){
					$lei[$k3]['worker_name'] = $v4['worker_name'];
				}
				$lei[$k3]['sum'] = $v3['sum'];
			}
			// 排序
			$sums = array();
			foreach($lei as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$lei);
			$lname1 = 0;
	        $lsum1 = 0;
			$b = count($lei);
			for($i=0;$i<$b;$i++){
				$lname1 .= $lei[$i]['worker_name'] . ',';
				$lsum1 .= $lei[$i]['sum'] . ',';
			}
			$lname1 = substr($lname1,1);
			$lsum1 = substr($lsum1,1);
			$lname = rtrim($lname1,',');
			$lsum = rtrim($lsum1,',');
			$this->assign('three1',$three1);
			$this->assign('lname',$lname);
			$this->assign('lsum',$lsum);
			$this->assign('posts',$posts['posts_name']);
			$this->display();
		}elseif(empty($detail)){
			// 计算entry表中的数据
			foreach($entry as $k4 => $v4){
				$score3[] = $v4['score_id'];
			}
			$score4 = array_unique($score3);
			foreach($score4 as $k5 => $v5){
                $list2[$k5]['id'] = $v5;
                $tj1['score_id'] = $v5;
                $tj1['mtime'] = array('in',$ctime2);
                $tj1['ktime'] = $notes['ktime'];
                $entry1[] = M('entry')->where($tj1)->select();
            }
            foreach($score4 as $k5 => $v5){
                foreach($entry1 as $k6 => $v6){
                    foreach($v6 as $k7 => $v7){
                        if($v5 == $v7['score_id']){
                            $list2[$k5]['cha'] += $v7['score'];
                        }
                    }
                }
            }
			foreach($score as $k9 => $v9){
                $score[$k9]['sum'] = 90;
				foreach($list2 as $k8 => $v8){
					if($v8['id'] == $v9['id']){
						$score[$k9]['sum'] = 90 + $v8['cha'];
					}
				}
			}
			$mp['ktime'] = $year;
			$mp['posts'] = $posts_id;
			$class0 = M('class')->where($mp)->order('class_id asc')->select();
			foreach($score as $key0 => $val0){
				if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
					$sum01[] = $val0['sum'];
					$count01 = count($sum01);
					$bfb = $count01 / $count * '100%';
					$bfb01 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
					$sum02[] = $val0['sum'];
					$count02 = count($sum02);
					$bfb = $count02 / $count * '100%';
					$bfb02 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
					$sum03[] = $val0['sum'];
					$count03 = count($sum03);
					$bfb = $count03 / $count * '100%';
					$bfb03 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
					$sum04[] = $val0['sum'];
					$count04 = count($sum04);
					$bfb = $count04 / $count * '100%';
					$bfb04 = round($bfb,2);
				}
			}
			if(empty($bfb01)){
				$bfb01 = 0;
			}
			if(empty($bfb02)){
				$bfb02 = 0;
			}
			if(empty($bfb03)){
				$bfb03 = 0;
			}
			if(empty($bfb04)){
				$bfb04 = 0;
			}
			$three1['0'] = $bfb01;
			$three1['1'] = $bfb02;
			$three1['2'] = $bfb03;
			$three1['3'] = $bfb04;
			$three1 = implode(',',$three1);
			// var_dump($three);die;
			foreach($score as $k3 => $v3){
				$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
				foreach($worker as $k4 => $v4){
					$lei[$k3]['worker_name'] = $v4['worker_name'];
				}
				$lei[$k3]['sum'] = $v3['sum'];
			}
			// 排序
			$sums = array();
			foreach($lei as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$lei);
			$lname1 = 0;
	        $lsum1 = 0;
			$b = count($lei);
			for($i=0;$i<$b;$i++){
				$lname1 .= $lei[$i]['worker_name'] . ',';
				$lsum1 .= $lei[$i]['sum'] . ',';
			}
			$lname1 = substr($lname1,1);
			$lsum1 = substr($lsum1,1);
			$lname = rtrim($lname1,',');
			$lsum = rtrim($lsum1,',');
			$this->assign('three1',$three1);
			$this->assign('lname',$lname);
			$this->assign('lsum',$lsum);
			$this->assign('posts',$posts['posts_name']);
			$this->display();
		}elseif(empty($entry)){
			// 计算detail表中的数据
			foreach($detail as $k1 => $v1){
				$score1[] = $v1['score_id'];
			}
			$score2 = array_unique($score1);
			foreach($score2 as $k2 => $v2){
                $list1[$k2]['id'] = $v2;
                $tj['score_id'] = $v2;
                $tj['mtime'] = array('in',$ctime1);
                $tj['ktime'] = $notes['ktime'];
                $detail1[] = M('detail')->where($tj)->select();
            }
            foreach($score2 as $k2 => $v2){
                foreach($detail1 as $k8 => $v8){
                    foreach($v8 as $k9 => $v9){
                        if($v2 == $v9['score_id']){
                            $list1[$k2]['cha'] += $v9['score'];
                        }
                    }
                }
            }
			foreach($score as $k9 => $v9){
                $score[$k9]['sum'] = 90;
				foreach($list1 as $k7 => $v7){
					if($v7['id'] == $v9['id']){
						$score[$k9]['sum'] = 90 + $v7['cha'];
					}
				}
			}
			$mp['ktime'] = $year;
			$mp['posts'] = $posts_id;
			$class0 = M('class')->where($mp)->order('class_id asc')->select();
			foreach($score as $key0 => $val0){
				if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
					$sum01[] = $val0['sum'];
					$count01 = count($sum01);
					$bfb = $count01 / $count * '100%';
					$bfb01 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
					$sum02[] = $val0['sum'];
					$count02 = count($sum02);
					$bfb = $count02 / $count * '100%';
					$bfb02 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
					$sum03[] = $val0['sum'];
					$count03 = count($sum03);
					$bfb = $count03 / $count * '100%';
					$bfb03 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
					$sum04[] = $val0['sum'];
					$count04 = count($sum04);
					$bfb = $count04 / $count * '100%';
					$bfb04 = round($bfb,2);
				}
			}
			if(empty($bfb01)){
				$bfb01 = 0;
			}
			if(empty($bfb02)){
				$bfb02 = 0;
			}
			if(empty($bfb03)){
				$bfb03 = 0;
			}
			if(empty($bfb04)){
				$bfb04 = 0;
			}
			$three1['0'] = $bfb01;
			$three1['1'] = $bfb02;
			$three1['2'] = $bfb03;
			$three1['3'] = $bfb04;
			$three1 = implode(',',$three1);
			// var_dump($three);die;
			foreach($score as $k3 => $v3){
				$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
				foreach($worker as $k4 => $v4){
					$lei[$k3]['worker_name'] = $v4['worker_name'];
				}
				$lei[$k3]['sum'] = $v3['sum'];
			}
			// 排序
			$sums = array();
			foreach($lei as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$lei);
			$lname1 = 0;
	        $lsum1 = 0;
			$b = count($lei);
			for($i=0;$i<$b;$i++){
				$lname1 .= $lei[$i]['worker_name'] . ',';
				$lsum1 .= $lei[$i]['sum'] . ',';
			}
			$lname1 = substr($lname1,1);
			$lsum1 = substr($lsum1,1);
			$lname = rtrim($lname1,',');
			$lsum = rtrim($lsum1,',');
			$this->assign('three1',$three1);
			$this->assign('lname',$lname);
			$this->assign('lsum',$lsum);
			$this->assign('posts',$posts['posts_name']);
			$this->display();
		}else{
			// 计算detail表和entry表中的数据和
			foreach($detail as $k1 => $v1){
				$score1[] = $v1['score_id'];
			}
			$score2 = array_unique($score1);
            // var_dump($score2);
			foreach($score2 as $k2 => $v2){
                $list1[$k2]['id'] = $v2;
                $tj['score_id'] = $v2;
                $tj['mtime'] = array('in',$ctime1);
                $tj['ktime'] = $notes['ktime'];
                $detail1[] = M('detail')->where($tj)->select();
            }
            foreach($score2 as $k2 => $v2){
                foreach($detail1 as $k8 => $v8){
                    foreach($v8 as $k9 => $v9){
                        if($v2 == $v9['score_id']){
                            $list1[$k2]['cha'] += $v9['score'];
                        }
                    }
                }
            }
            foreach($entry as $k4 => $v4){
				$score3[] = $v4['score_id'];
			}
			$score4 = array_unique($score3);
            // var_dump($score4);die;
			foreach($score4 as $k5 => $v5){
				$list2[$k5]['id'] = $v5;
				$tj1['score_id'] = $v5;
				$tj1['mtime'] = array('in',$ctime2);
				$tj1['ktime'] = $notes['ktime'];
				$entry1[] = M('entry')->where($tj1)->select();
            }
            foreach($score4 as $k5 => $v5){
                foreach($entry1 as $k6 => $v6){
                    foreach($v6 as $k7 => $v7){
                        if($v5 == $v7['score_id']){
                            $list2[$k5]['cha'] += $v7['score'];
                        }
                    }
                }
            }
            // echo "<pre>";
            // var_dump($list2);
            // echo "</pre>";
            $list = array_merge_recursive($list1,$list2);
            foreach($list as $key => $val){
                $deen[] = $val['id'];
            }
            $deen1 = array_unique($deen);
            foreach($list as $key1 => $val1){
                foreach($deen1 as $key2 => $val2){
                    if($val2 == $val1['id']){
                        $li[$key2]['id'] = $val1['id'];
                        $li[$key2]['cha'] += $val1['cha'];
                    }
                }
            }
            // echo "<pre>";
            // var_dump($score);
            // echo "</pre>";
            foreach($score as $key3 => $val3){
                $score[$key3]['sum'] = 90;
                foreach($li as $key4 => $val4){
                    if($val4['id'] == $val3['id']){
                        $score[$key3]['sum'] = 90 + $val4['cha'];
                    }
                }
            }
            // echo "<pre>";
            // var_dump($score);
            // echo "</pre>";die;
			$mp['ktime'] = $year;
			$mp['posts'] = $posts_id;
			$class0 = M('class')->where($mp)->order('class_id asc')->select();
			foreach($score as $key0 => $val0){
				if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
					$sum01[] = $val0['sum'];
					$count01 = count($sum01);
					$bfb = $count01 / $count * '100%';
					$bfb01 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
					$sum02[] = $val0['sum'];
					$count02 = count($sum02);
					$bfb = $count02 / $count * '100%';
					$bfb02 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
					$sum03[] = $val0['sum'];
					$count03 = count($sum03);
					$bfb = $count03 / $count * '100%';
					$bfb03 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
					$sum04[] = $val0['sum'];
					$count04 = count($sum04);
					$bfb = $count04 / $count * '100%';
					$bfb04 = round($bfb,2);
				}
			}
			if(empty($bfb01)){
				$bfb01 = 0;
			}
			if(empty($bfb02)){
				$bfb02 = 0;
			}
			if(empty($bfb03)){
				$bfb03 = 0;
			}
			if(empty($bfb04)){
				$bfb04 = 0;
			}
			$three1['0'] = $bfb01;
			$three1['1'] = $bfb02;
			$three1['2'] = $bfb03;
			$three1['3'] = $bfb04;
			$three1 = implode(',',$three1);
			// var_dump($three);die;
			foreach($score as $k3 => $v3){
				$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
				foreach($worker as $k4 => $v4){
					$lei[$k3]['worker_name'] = $v4['worker_name'];
				}
				$lei[$k3]['sum'] = $v3['sum'];
			}
			// 排序
			$sums = array();
			foreach($lei as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$lei);
			$lname1 = 0;
	        $lsum1 = 0;
			$b = count($lei);
			for($i=0;$i<$b;$i++){
				$lname1 .= $lei[$i]['worker_name'] . ',';
				$lsum1 .= $lei[$i]['sum'] . ',';
			}
			$lname1 = substr($lname1,1);
			$lsum1 = substr($lsum1,1);
			$lname = rtrim($lname1,',');
			$lsum = rtrim($lsum1,',');
			$this->assign('three1',$three1);
			$this->assign('lname',$lname);
			$this->assign('lsum',$lsum);
			$this->assign('posts',$posts['posts_name']);
			$this->display();
		}
	}

	// 第三个图 月份选择下拉框ajax请求
	public function three2(){
		// var_dump($_POST);die;
		$id = $_POST['id']; // 考核表id
		$month = $_POST['month']; // 月份
		$posts_id = $_POST['posts_id']; // 岗位id
		$posts = M('posts')->where('posts_id='.$posts_id)->find();
		$notes = M('notes')->where('id='.$id)->find();
		$year = date("Y",$notes['ktime']);
		$cposts = M('posts')->where('parent_id='.$posts_id)->select();
		foreach($cposts as $k1 => $v1){
			$cpos[] = $v1['posts_id'];
		}
		$mp1['posts_id'] = array('in',$cpos);
		$mp1['test_time'] = $notes['ktime'];
		$score = M('score')->where($mp1)->select();
		$count = count($score);
		foreach($score as $k2 => $v2){
			$score_id[] = $v2['id'];
		}
		if($month == '01'){
			$ctime1 = strtotime($year .'-'. $month); // 要查看的年-月
			$ctime2 = $year . '-' . $month;
			$map1['mtime'] = $ctime1;
			$map1['score_id'] = array('in',$score_id);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = $ctime2;
			$map2['score_id'] = array('in',$score_id);
			$map2['ktime'] = $notes['ktime'];
		}else{
			for($i = 1;$i <= $month;$i++){
				$a[] = $i;
			}
			foreach($a as $k => $v){
				$ctime1[] = strtotime($year .'-'. $v);
				if($v == 10){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
				}elseif($v == 11){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
					$ctime2['10'] = $year . '-' . '11';
				}elseif($v == 12){
					$ctime2[] = $year . '-0' . $v;
					$ctime2['9'] = $year . '-' . '10';
					$ctime2['10'] = $year . '-' . '11';
					$ctime2['11'] = $year . '-' . '12';
				}else{
					$ctime2[] = $year . '-0' . $v;
				}
			}
			$map1['mtime'] = array('in',$ctime1);
			$map1['score_id'] = array('in',$score_id);
			$map1['ktime'] = $notes['ktime'];
			$map2['mtime'] = array('in',$ctime2);
			$map2['score_id'] = array('in',$score_id);
			$map2['ktime'] = $notes['ktime'];
		}
		$detail = M('detail')->where($map1)->select();
		$entry = M('entry')->where($map2)->select();
		if(empty($detail) && empty($entry)){
			// 默认值
			// var_dump($score);die;
			$mp['ktime'] = $year;
			$mp['posts'] = $posts_id;
			$class0 = M('class')->where($mp)->order('class_id asc')->select();
			foreach($score as $k => $v){
				$score[$k]['sum'] = 90;
			}
			foreach($score as $key0 => $val0){
				if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
					$sum01[] = $val0['sum'];
					$count01 = count($sum01);
					$bfb = $count01 / $count * '100%';
					$bfb01 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
					$sum02[] = $val0['sum'];
					$count02 = count($sum02);
					$bfb = $count02 / $count * '100%';
					$bfb02 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
					$sum03[] = $val0['sum'];
					$count03 = count($sum03);
					$bfb = $count03 / $count * '100%';
					$bfb03 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
					$sum04[] = $val0['sum'];
					$count04 = count($sum04);
					$bfb = $count04 / $count * '100%';
					$bfb04 = round($bfb,2);
				}
			}
			if(empty($bfb01)){
				$bfb01 = 0;
			}
			if(empty($bfb02)){
				$bfb02 = 0;
			}
			if(empty($bfb03)){
				$bfb03 = 0;
			}
			if(empty($bfb04)){
				$bfb04 = 0;
			}
			$three2['0'] = $bfb01;
			$three2['1'] = $bfb02;
			$three2['2'] = $bfb03;
			$three2['3'] = $bfb04;
			$three2 = implode(',',$three2);
			// var_dump($three);die;
			foreach($score as $k3 => $v3){
				$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
				foreach($worker as $k4 => $v4){
					$lei[$k3]['worker_name'] = $v4['worker_name'];
				}
				$lei[$k3]['sum'] = $v3['sum'];
			}
			// 排序
			$sums = array();
			foreach($lei as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$lei);
			$lname1 = 0;
	        $lsum1 = 0;
			$b = count($lei);
			for($i=0;$i<$b;$i++){
				$lname1 .= $lei[$i]['worker_name'] . ',';
				$lsum1 .= $lei[$i]['sum'] . ',';
			}
			$lname1 = substr($lname1,1);
			$lsum1 = substr($lsum1,1);
			$lname = rtrim($lname1,',');
			$lsum = rtrim($lsum1,',');
			$this->assign('three2',$three2);
			$this->assign('lname',$lname);
			$this->assign('lsum',$lsum);
			$this->assign('posts',$posts['posts_name']);
			$this->display();
		}elseif(empty($detail)){
			// 计算entry表中的数据
			foreach($entry as $k4 => $v4){
				$score3[] = $v4['score_id'];
			}
			$score4 = array_unique($score3);
			foreach($score4 as $k5 => $v5){
                $list2[$k5]['id'] = $v5;
                $tj1['score_id'] = $v5;
                $tj1['mtime'] = array('in',$ctime2);
                $tj1['ktime'] = $notes['ktime'];
                $entry1[] = M('entry')->where($tj1)->select();
            }
            foreach($score4 as $k5 => $v5){
                foreach($entry1 as $k6 => $v6){
                    foreach($v6 as $k7 => $v7){
                        if($v5 == $v7['score_id']){
                            $list2[$k5]['cha'] += $v7['score'];
                        }
                    }
                }
            }
			foreach($score as $k9 => $v9){
                $score[$k9]['sum'] = 90;
				foreach($list2 as $k8 => $v8){
					if($v8['id'] == $v9['id']){
						$score[$k9]['sum'] = 90 + $v8['cha'];
					}
				}
			}
			$mp['ktime'] = $year;
			$mp['posts'] = $posts_id;
			$class0 = M('class')->where($mp)->order('class_id asc')->select();
			foreach($score as $key0 => $val0){
				if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
					$sum01[] = $val0['sum'];
					$count01 = count($sum01);
					$bfb = $count01 / $count * '100%';
					$bfb01 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
					$sum02[] = $val0['sum'];
					$count02 = count($sum02);
					$bfb = $count02 / $count * '100%';
					$bfb02 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
					$sum03[] = $val0['sum'];
					$count03 = count($sum03);
					$bfb = $count03 / $count * '100%';
					$bfb03 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
					$sum04[] = $val0['sum'];
					$count04 = count($sum04);
					$bfb = $count04 / $count * '100%';
					$bfb04 = round($bfb,2);
				}
			}
			if(empty($bfb01)){
				$bfb01 = 0;
			}
			if(empty($bfb02)){
				$bfb02 = 0;
			}
			if(empty($bfb03)){
				$bfb03 = 0;
			}
			if(empty($bfb04)){
				$bfb04 = 0;
			}
			$three2['0'] = $bfb01;
			$three2['1'] = $bfb02;
			$three2['2'] = $bfb03;
			$three2['3'] = $bfb04;
			$three2 = implode(',',$three2);
			// var_dump($three);die;
			foreach($score as $k3 => $v3){
				$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
				foreach($worker as $k4 => $v4){
					$lei[$k3]['worker_name'] = $v4['worker_name'];
				}
				$lei[$k3]['sum'] = $v3['sum'];
			}
			// 排序
			$sums = array();
			foreach($lei as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$lei);
			$lname1 = 0;
	        $lsum1 = 0;
			$b = count($lei);
			for($i=0;$i<$b;$i++){
				$lname1 .= $lei[$i]['worker_name'] . ',';
				$lsum1 .= $lei[$i]['sum'] . ',';
			}
			$lname1 = substr($lname1,1);
			$lsum1 = substr($lsum1,1);
			$lname = rtrim($lname1,',');
			$lsum = rtrim($lsum1,',');
			$this->assign('three2',$three2);
			$this->assign('lname',$lname);
			$this->assign('lsum',$lsum);
			$this->assign('posts',$posts['posts_name']);
			$this->display();
		}elseif(empty($entry)){
			// 计算detail表中的数据
			foreach($detail as $k1 => $v1){
				$score1[] = $v1['score_id'];
			}
			$score2 = array_unique($score1);
			foreach($score2 as $k2 => $v2){
                $list1[$k2]['id'] = $v2;
                $tj['score_id'] = $v2;
                $tj['mtime'] = array('in',$ctime1);
                $tj['ktime'] = $notes['ktime'];
                $detail1[] = M('detail')->where($tj)->select();
            }
            foreach($score2 as $k2 => $v2){
                foreach($detail1 as $k8 => $v8){
                    foreach($v8 as $k9 => $v9){
                        if($v2 == $v9['score_id']){
                            $list1[$k2]['cha'] += $v9['score'];
                        }
                    }
                }
            }
			foreach($score as $k9 => $v9){
                $score[$k9]['sum'] = 90;
				foreach($list1 as $k7 => $v7){
					if($v7['id'] == $v9['id']){
						$score[$k9]['sum'] = 90 + $v7['cha'];
					}
				}
			}
			$mp['ktime'] = $year;
			$mp['posts'] = $posts_id;
			$class0 = M('class')->where($mp)->order('class_id asc')->select();
			foreach($score as $key0 => $val0){
				if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
					$sum01[] = $val0['sum'];
					$count01 = count($sum01);
					$bfb = $count01 / $count * '100%';
					$bfb01 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
					$sum02[] = $val0['sum'];
					$count02 = count($sum02);
					$bfb = $count02 / $count * '100%';
					$bfb02 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
					$sum03[] = $val0['sum'];
					$count03 = count($sum03);
					$bfb = $count03 / $count * '100%';
					$bfb03 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
					$sum04[] = $val0['sum'];
					$count04 = count($sum04);
					$bfb = $count04 / $count * '100%';
					$bfb04 = round($bfb,2);
				}
			}
			if(empty($bfb01)){
				$bfb01 = 0;
			}
			if(empty($bfb02)){
				$bfb02 = 0;
			}
			if(empty($bfb03)){
				$bfb03 = 0;
			}
			if(empty($bfb04)){
				$bfb04 = 0;
			}
			$three2['0'] = $bfb01;
			$three2['1'] = $bfb02;
			$three2['2'] = $bfb03;
			$three2['3'] = $bfb04;
			$three2 = implode(',',$three2);
			// var_dump($three);die;
			foreach($score as $k3 => $v3){
				$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
				foreach($worker as $k4 => $v4){
					$lei[$k3]['worker_name'] = $v4['worker_name'];
				}
				$lei[$k3]['sum'] = $v3['sum'];
			}
			// 排序
			$sums = array();
			foreach($lei as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$lei);
			$lname1 = 0;
	        $lsum1 = 0;
			$b = count($lei);
			for($i=0;$i<$b;$i++){
				$lname1 .= $lei[$i]['worker_name'] . ',';
				$lsum1 .= $lei[$i]['sum'] . ',';
			}
			$lname1 = substr($lname1,1);
			$lsum1 = substr($lsum1,1);
			$lname = rtrim($lname1,',');
			$lsum = rtrim($lsum1,',');
			$this->assign('three2',$three2);
			$this->assign('lname',$lname);
			$this->assign('lsum',$lsum);
			$this->assign('posts',$posts['posts_name']);
			$this->display();
		}else{
			// 计算detail表和entry表中的数据和
			foreach($detail as $k1 => $v1){
                $score1[] = $v1['score_id'];
            }
            $score2 = array_unique($score1);
            // var_dump($score2);
            foreach($score2 as $k2 => $v2){
                $list1[$k2]['id'] = $v2;
                $tj['score_id'] = $v2;
                $tj['mtime'] = array('in',$ctime1);
                $tj['ktime'] = $notes['ktime'];
                $detail1[] = M('detail')->where($tj)->select();
            }
            foreach($score2 as $k2 => $v2){
                foreach($detail1 as $k8 => $v8){
                    foreach($v8 as $k9 => $v9){
                        if($v2 == $v9['score_id']){
                            $list1[$k2]['cha'] += $v9['score'];
                        }
                    }
                }
            }
            foreach($entry as $k4 => $v4){
                $score3[] = $v4['score_id'];
            }
            $score4 = array_unique($score3);
            // var_dump($score4);die;
            foreach($score4 as $k5 => $v5){
                $list2[$k5]['id'] = $v5;
                $tj1['score_id'] = $v5;
                $tj1['mtime'] = array('in',$ctime2);
                $tj1['ktime'] = $notes['ktime'];
                $entry1[] = M('entry')->where($tj1)->select();
            }
            foreach($score4 as $k5 => $v5){
                foreach($entry1 as $k6 => $v6){
                    foreach($v6 as $k7 => $v7){
                        if($v5 == $v7['score_id']){
                            $list2[$k5]['cha'] += $v7['score'];
                        }
                    }
                }
            }
            // echo "<pre>";
            // var_dump($list2);
            // echo "</pre>";
            $list = array_merge_recursive($list1,$list2);
            foreach($list as $key => $val){
                $deen[] = $val['id'];
            }
            $deen1 = array_unique($deen);
            foreach($list as $key1 => $val1){
                foreach($deen1 as $key2 => $val2){
                    if($val2 == $val1['id']){
                        $li[$key2]['id'] = $val1['id'];
                        $li[$key2]['cha'] += $val1['cha'];
                    }
                }
            }
            // echo "<pre>";
            // var_dump($score);
            // echo "</pre>";
            foreach($score as $key3 => $val3){
                $score[$key3]['sum'] = 90;
                foreach($li as $key4 => $val4){
                    if($val4['id'] == $val3['id']){
                        $score[$key3]['sum'] = 90 + $val4['cha'];
                    }
                }
            }
			$mp['ktime'] = $year;
			$mp['posts'] = $posts_id;
			$class0 = M('class')->where($mp)->order('class_id asc')->select();
			foreach($score as $key0 => $val0){
				if($val0['sum'] >= $class0['0']['bottom'] && $val0['sum'] < $class0['0']['top']){
					$sum01[] = $val0['sum'];
					$count01 = count($sum01);
					$bfb = $count01 / $count * '100%';
					$bfb01 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['1']['bottom'] && $val0['sum'] < $class0['1']['top']){
					$sum02[] = $val0['sum'];
					$count02 = count($sum02);
					$bfb = $count02 / $count * '100%';
					$bfb02 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['2']['bottom'] && $val0['sum'] < $class0['2']['top']){
					$sum03[] = $val0['sum'];
					$count03 = count($sum03);
					$bfb = $count03 / $count * '100%';
					$bfb03 = round($bfb,2);
				}elseif($val0['sum'] >= $class0['3']['bottom'] && $val0['sum'] < $class0['3']['top']){
					$sum04[] = $val0['sum'];
					$count04 = count($sum04);
					$bfb = $count04 / $count * '100%';
					$bfb04 = round($bfb,2);
				}
			}
			if(empty($bfb01)){
				$bfb01 = 0;
			}
			if(empty($bfb02)){
				$bfb02 = 0;
			}
			if(empty($bfb03)){
				$bfb03 = 0;
			}
			if(empty($bfb04)){
				$bfb04 = 0;
			}
			$three2['0'] = $bfb01;
			$three2['1'] = $bfb02;
			$three2['2'] = $bfb03;
			$three2['3'] = $bfb04;
			$three2 = implode(',',$three2);
			// var_dump($three);die;
			foreach($score as $k3 => $v3){
				$worker[] = M('worker')->where('worker_id='.$v3['worker_id'])->find();
				foreach($worker as $k4 => $v4){
					$lei[$k3]['worker_name'] = $v4['worker_name'];
				}
				$lei[$k3]['sum'] = $v3['sum'];
			}
			// 排序
			$sums = array();
			foreach($lei as $li){
				$sums[] = $li['sum'];
			}
			array_multisort($sums,SORT_DESC,$lei);
			$lname1 = 0;
	        $lsum1 = 0;
			$b = count($lei);
			for($i=0;$i<$b;$i++){
				$lname1 .= $lei[$i]['worker_name'] . ',';
				$lsum1 .= $lei[$i]['sum'] . ',';
			}
			$lname1 = substr($lname1,1);
			$lsum1 = substr($lsum1,1);
			$lname = rtrim($lname1,',');
			$lsum = rtrim($lsum1,',');
			$this->assign('three2',$three2);
			$this->assign('lname',$lname);
			$this->assign('lsum',$lsum);
			$this->assign('posts',$posts['posts_name']);
			$this->display();
		}
	}

	// 第四个图 季度选择下拉框ajax请求
    public function four1(){
        // var_dump($_POST);die;
        $id = $_POST['id']; // 考核表id
        $quarter = $_POST['quarter']; // 季度
        $notes = M('notes')->where('id='.$id)->find();
        $year = date("Y",$notes['ktime']);
        $mp1['test_time'] = $notes['ktime'];
        $score = M('score')->where($mp1)->select();
        foreach($score as $k2 => $v2){
            $score_id[] = $v2['id'];
        }
        $team1 = M('team')->order('team_id asc')->select();
        foreach($team1 as $key => $value){
            $team_name[] = $value['team_name'];
            $worker[$key] = M('worker')->where('team_id='.$value['team_id'])->select();
        }
        $team = implode(',',$team_name); // 部门名称
        foreach($worker as $key1 => $value1){
            foreach($value1 as $key2 => $value2){
                $bum[$key1][] = $value2['worker_id']; // 每个部门所有人员id
            }
        }
        foreach($score as $key3 => $value3){
            $sworker[$key3] = $value3['worker_id']; // 最新考核表下考核人员
        }
        foreach($bum as $key4 => $value4){
            $bum1[$key4] = array_intersect($sworker,$value4); // 每个部门考核人员
            $bumcount[$key4] = count($value4); // 每个部门人数
        }
        // var_dump($bumcount);die;
        foreach($bum1 as $key5 => $value5){
            if(empty($value5)){
                $bumen1[] = $key5; // 考核人员为空的部门
                foreach($team_name as $key6 => $value6){
                    foreach($bumen1 as $key7 => $value7){
                        if($key6 == $value7){
                            $pbumen1[$key5]['team_name'] = $value6; // 考核人员为空的部门
                            $pbumen1[$key5]['fen'] = 0; // 考核人员为空的部门平均分数
                        }
                    }
                }
            }else{
                $bumen2[] = $key5; // 考核人员不为空的部门
                $brenyuan[$key5] = $value5; // 考核部门不为空的部门人员id
                foreach($brenyuan as $key8 => $value8){
                    foreach($value8 as $key9 => $value9){
                        foreach($score as $key10 => $value10){
                            $kaohe[$key10]['worker_id'] = $value10['worker_id'];
                            $kaohe[$key10]['score_id'] = $value10['id'];
                            if($value9 == $value10['worker_id']){
                                $kaohe[$key10]['team_id'] = $key8;
                            }
                        }
                    }
                }
            }
        }
        if($quarter == '1'){
            for($i = 1;$i <= 3;$i++){
                $a[] = $i;
            }
            foreach($a as $k => $v){
                $ctime1[] = strtotime($year .'-'.$v);
                $ctime2[] = $year . '-0' . $v;
            }
            $map1['mtime'] = array('in',$ctime1);
            $map1['score_id'] = array('in',$score_id);
            $map1['ktime'] = $notes['ktime'];
            $map2['mtime'] = array('in',$ctime2);
            $map2['score_id'] = array('in',$score_id);
            $map2['ktime'] = $notes['ktime'];
        }elseif($quarter == '2'){
            for($i = 1;$i <= 6;$i++){
                $a[] = $i;
            }
            foreach($a as $k => $v){
                $ctime1[] = strtotime($year .'-'.$v);
                $ctime2[] = $year . '-0' . $v;
            }
            $map1['mtime'] = array('in',$ctime1);
            $map1['score_id'] = array('in',$score_id);
            $map1['ktime'] = $notes['ktime'];
            $map2['mtime'] = array('in',$ctime2);
            $map2['score_id'] = array('in',$score_id);
            $map2['ktime'] = $notes['ktime'];
        }elseif($quarter == '3'){
            for($i = 1;$i <= 9;$i++){
                $a[] = $i;
            }
            foreach($a as $k => $v){
                $ctime1[] = strtotime($year .'-'.$v);
                $ctime2[] = $year . '-0' . $v;
            }
            $map1['mtime'] = array('in',$ctime1);
            $map1['score_id'] = array('in',$score_id);
            $map1['ktime'] = $notes['ktime'];
            $map2['mtime'] = array('in',$ctime2);
            $map2['score_id'] = array('in',$score_id);
            $map2['ktime'] = $notes['ktime'];
        }elseif($quarter == '4'){
            for($i = 1;$i <= 12;$i++){
                $a[] = $i;
            }
            foreach($a as $k => $v){
                $ctime1[] = strtotime($year .'-'.$v);
                if($v == 10){
                    $ctime2[] = $year . '-0' . $v;
                    $ctime2['9'] = $year . '-' . '10';
                }elseif($v == 11){
                    $ctime2[] = $year . '-0' . $v;
                    $ctime2['9'] = $year . '-' . '10';
                    $ctime2['10'] = $year . '-' . '11';
                }elseif($v == 12){
                    $ctime2[] = $year . '-0' . $v;
                    $ctime2['9'] = $year . '-' . '10';
                    $ctime2['10'] = $year . '-' . '11';
                    $ctime2['11'] = $year . '-' . '12';
                }else{
                    $ctime2[] = $year . '-0' . $v;
                }
            }
            $map1['mtime'] = array('in',$ctime1);
            $map1['score_id'] = array('in',$score_id);
            $map1['ktime'] = $notes['ktime'];
            $map2['mtime'] = array('in',$ctime2);
            $map2['score_id'] = array('in',$score_id);
            $map2['ktime'] = $notes['ktime'];
        }
        $detail4 = M('detail')->where($map1)->select();
        $entry4 = M('entry')->where($map2)->select();
        if(empty($detail4) && empty($entry4)){
            foreach($kaohe as $key12 => $value12){
                $kaohe[$key12]['sum'] = 90;
            }
        }elseif(empty($detail4)){
            // 计算entry表中的数据
            foreach($entry4 as $k4 => $v4){
                $scor3[] = $v4['score_id'];
            }
            $scor4 = array_unique($scor3);
            // var_dump($score4);die;
            foreach($scor4 as $k5 => $v5){
                $res2[$k5]['id'] = $v5;
                $tj1['score_id'] = $v5;
                $tj1['mtime'] = array('in',$ctime2);
                $tj1['ktime'] = $notes['ktime'];
                $etry1[] = M('entry')->where($tj1)->select();
            }
            foreach($scor4 as $k5 => $v5){
                foreach($etry1 as $k6 => $v6){
                    foreach($v6 as $k7 => $v7){
                        if($v5 == $v7['score_id']){
                            $res2[$k5]['cha'] += $v7['score'];
                        }
                    }
                }
            }
            foreach($kaohe as $k9 => $v9){
                $kaohe[$k9]['sum'] = 90;
                foreach($li2 as $k8 => $v8){
                    if($v8['id'] == $v9['score_id']){
                        $kaohe[$k9]['sum'] = 90 + $v8['cha'];
                    }
                }
            }
        }elseif(empty($entry4)){
            // 计算detail表中的数据
            foreach($detail4 as $k1 => $v1){
                $scor1[] = $v1['score_id'];
            }
            $scor2 = array_unique($scor1);
            // var_dump($scor2);die;
            foreach($scor2 as $k2 => $v2){
                $res1[$k2]['id'] = $v2;
                $tj['score_id'] = $v2;
                $tj['mtime'] = array('in',$ctime1);
                $tj['ktime'] = $notes['ktime'];
                $detil1[] = M('detail')->where($tj)->select();
            }
            foreach($scor2 as $k2 => $v2){
                foreach($detil1 as $k8 => $v8){
                    foreach($v8 as $k9 => $v9){
                        if($v2 == $v9['score_id']){
                            $res1[$k2]['cha'] += $v9['score'];
                        }
                    }
                }
            }
            foreach($kaohe as $k9 => $v9){
                $kaohe[$k9]['sum'] = 90;
                foreach($res1 as $k7 => $v7){
                    if($v7['id'] == $v9['score_id']){
                        $kaohe[$k9]['sum'] = 90 + $v7['cha'];
                    }
                }
            }
        }else{
            // 计算detail表和entry表中的数据和
            foreach($detail4 as $k1 => $v1){
                $scor1[] = $v1['score_id'];
            }
            $scor2 = array_unique($scor1);
            // var_dump($scor2);die;
            foreach($scor2 as $k2 => $v2){
                $res1[$k2]['id'] = $v2;
                $tj['score_id'] = $v2;
                $tj['mtime'] = array('in',$ctime1);
                $tj['ktime'] = $notes['ktime'];
                $detil1[] = M('detail')->where($tj)->select();
            }
            foreach($scor2 as $k2 => $v2){
                foreach($detil1 as $k8 => $v8){
                    foreach($v8 as $k9 => $v9){
                        if($v2 == $v9['score_id']){
                            $res1[$k2]['cha'] += $v9['score'];
                        }
                    }
                }
            }
            // echo "<pre>";
            // var_dump($res1);
            // echo "</pre>";
            foreach($entry4 as $k4 => $v4){
                $scor3[] = $v4['score_id'];
            }
            $scor4 = array_unique($scor3);
            // var_dump($score4);die;
            foreach($scor4 as $k5 => $v5){
                $res2[$k5]['id'] = $v5;
                $tj1['score_id'] = $v5;
                $tj1['mtime'] = array('in',$ctime2);
                $tj1['ktime'] = $notes['ktime'];
                $etry1[] = M('entry')->where($tj1)->select();
            }
            foreach($scor4 as $k5 => $v5){
                foreach($etry1 as $k6 => $v6){
                    foreach($v6 as $k7 => $v7){
                        if($v5 == $v7['score_id']){
                            $res2[$k5]['cha'] += $v7['score'];
                        }
                    }
                }
            }
            // echo "<pre>";
            // var_dump($res2);
            // echo "</pre>";die;
            $lis = array_merge_recursive($res1,$res2);
            foreach($lis as $key => $val){
                $deen[] = $val['id'];
            }
            $deen1 = array_unique($deen);
            foreach($lis as $key1 => $val1){
                foreach($deen1 as $key2 => $val2){
                    if($val2 == $val1['id']){
                        $li3[$key2]['id'] = $val1['id'];
                        $li3[$key2]['cha'] += $val1['cha'];
                    }
                }
            }
            // echo "<pre>";
            // var_dump($li3);
            // echo "</pre>";die;
            foreach($kaohe as $key3 => $val3){
                $kaohe[$key3]['sum'] = 90;
                foreach($li3 as $key4 => $val4){
                    if($val4['id'] == $val3['score_id']){
                        $kaohe[$key3]['sum'] = 90 + $val4['cha'];
                    }
                }
            }
        }
        // var_dump($kaohe);die;
        foreach($bumen2 as $key12 => $value12){
            foreach($kaohe as $key13 => $value13){
                if($value12 == $value13['team_id']){
                    $pbumen2[$value12] += $value13['sum']; // 各部门总分数
                }
            }
            foreach($pbumen2 as $key14 => $value14){
                foreach($team_name as $key16 => $value16){
                    if($key14 == $key16){
                        $pbumen3[$key14]['team_name'] = $value16;
                    }
                }
                foreach($bumcount as $key15 => $value15){
                    if($key14 == $key15){
                        $pbumen3[$key14]['fen'] = round($value14 / $value15,2);
                    }
                }
            }
        }
        $pbumen4 = $pbumen1 + $pbumen3;
        ksort($pbumen4);
        // echo "<pre>";
        // var_dump($pbumen4);
        // echo "</pre>";die;
        foreach($pbumen4 as $key17 => $value17){
            $pb_name1[] = $value17['team_name'];
            $pb_fen1[] = $value17['fen'];
        }
        $pb_name = implode(',',$pb_name1);
        $pb_fen = implode(',',$pb_fen1);
        // var_dump($pb_name);
        // var_dump($pb_fen);
        // var_dump($month);die;
        if($quarter == '1'){
            $month = '第一季度';
        }elseif($quarter == '2'){
            $month = '第二季度';
        }elseif($quarter == '3'){
            $month = '第三季度';
        }else{
            $month = '第四季度';
        }
        $this->assign('team',$team);
        $this->assign('pb_name',$pb_name);
        $this->assign('pb_fen',$pb_fen);
        $this->assign('month',$month);
        $this->display();
    }

    // 第四个图 月份选择下拉框ajax请求
    public function four2(){
        // var_dump($_POST);die;
        $id = $_POST['id']; // 考核表id
        $month = $_POST['month']; // 月份
        $notes = M('notes')->where('id='.$id)->find();
        $year = date("Y",$notes['ktime']);
        $mp1['test_time'] = $notes['ktime'];
        $score = M('score')->where($mp1)->select();
        foreach($score as $k2 => $v2){
            $score_id[] = $v2['id'];
        }
        $team1 = M('team')->order('team_id asc')->select();
        foreach($team1 as $key => $value){
            $team_name[] = $value['team_name'];
            $worker[$key] = M('worker')->where('team_id='.$value['team_id'])->select();
        }
        $team = implode(',',$team_name); // 部门名称
        foreach($worker as $key1 => $value1){
            foreach($value1 as $key2 => $value2){
                $bum[$key1][] = $value2['worker_id']; // 每个部门所有人员id
            }
        }
        foreach($score as $key3 => $value3){
            $sworker[$key3] = $value3['worker_id']; // 最新考核表下考核人员
        }
        foreach($bum as $key4 => $value4){
            $bum1[$key4] = array_intersect($sworker,$value4); // 每个部门考核人员
            $bumcount[$key4] = count($value4); // 每个部门人数
        }
        // var_dump($bumcount);die;
        foreach($bum1 as $key5 => $value5){
            if(empty($value5)){
                $bumen1[] = $key5; // 考核人员为空的部门
                foreach($team_name as $key6 => $value6){
                    foreach($bumen1 as $key7 => $value7){
                        if($key6 == $value7){
                            $pbumen1[$key5]['team_name'] = $value6; // 考核人员为空的部门
                            $pbumen1[$key5]['fen'] = 0; // 考核人员为空的部门平均分数
                        }
                    }
                }
            }else{
                $bumen2[] = $key5; // 考核人员不为空的部门
                $brenyuan[$key5] = $value5; // 考核部门不为空的部门人员id
                foreach($brenyuan as $key8 => $value8){
                    foreach($value8 as $key9 => $value9){
                        foreach($score as $key10 => $value10){
                            $kaohe[$key10]['worker_id'] = $value10['worker_id'];
                            $kaohe[$key10]['score_id'] = $value10['id'];
                            if($value9 == $value10['worker_id']){
                                $kaohe[$key10]['team_id'] = $key8;
                            }
                        }
                    }
                }
            }
        }
        // var_dump($kaohe);die;
        if($month == '1'){
            $ctime1 = strtotime($year .'-0'. $month); // 要查看的年-月
            $ctime2 = $year . '-0' . $month;
            $map1['mtime'] = $ctime1;
            $map1['score_id'] = array('in',$score_id);
            $map1['ktime'] = $notes['ktime'];
            $map2['mtime'] = $ctime2;
            $map2['score_id'] = array('in',$score_id);
            $map2['ktime'] = $notes['ktime'];
        }else{
            for($i = 1;$i <= $month;$i++){
                $a[] = $i;
            }
            foreach($a as $k => $v){
                $ctime1[] = strtotime($year .'-'. $v);
                if($v == 10){
                    $ctime2[] = $year . '-0' . $v;
                    $ctime2['9'] = $year . '-' . '10';
                }elseif($v == 11){
                    $ctime2[] = $year . '-0' . $v;
                    $ctime2['9'] = $year . '-' . '10';
                    $ctime2['10'] = $year . '-' . '11';
                }elseif($v == 12){
                    $ctime2[] = $year . '-0' . $v;
                    $ctime2['9'] = $year . '-' . '10';
                    $ctime2['10'] = $year . '-' . '11';
                    $ctime2['11'] = $year . '-' . '12';
                }else{
                    $ctime2[] = $year . '-0' . $v;
                }
            }
            $map1['mtime'] = array('in',$ctime1);
            $map1['score_id'] = array('in',$score_id);
            $map1['ktime'] = $notes['ktime'];
            $map2['mtime'] = array('in',$ctime2);
            $map2['score_id'] = array('in',$score_id);
            $map2['ktime'] = $notes['ktime'];
        }
        $detail4 = M('detail')->where($map1)->select();
        $entry4 = M('entry')->where($map2)->select();
        if(empty($detail4) && empty($entry4)){
            foreach($kaohe as $key12 => $value12){
                $kaohe[$key12]['sum'] = 90;
            }
        }elseif(empty($detail4)){
            // 计算entry表中的数据
            foreach($entry4 as $k4 => $v4){
                $scor3[] = $v4['score_id'];
            }
            $scor4 = array_unique($scor3);
            // var_dump($scor4);die;
            foreach($scor4 as $k5 => $v5){
                $res2[$k5]['id'] = $v5;
                $tj1['score_id'] = $v5;
                $tj1['mtime'] = array('in',$ctime2);
                $tj1['ktime'] = $notes['ktime'];
                $etry1[] = M('entry')->where($tj1)->select();
            }
            foreach($scor4 as $k5 => $v5){
                foreach($etry1 as $k6 => $v6){
                    foreach($v6 as $k7 => $v7){
                        if($v5 == $v7['score_id']){
                            $res2[$k5]['cha'] += $v7['score'];
                        }
                    }
                }
            }
            foreach($kaohe as $k9 => $v9){
                $kaohe[$k9]['sum'] = 90;
                foreach($res2 as $k8 => $v8){
                    if($v8['id'] == $v9['score_id']){
                        $kaohe[$k9]['sum'] = 90 + $v8['cha'];
                    }
                }
            }
        }elseif(empty($entry4)){
            // 计算detail表中的数据
            foreach($detail4 as $k1 => $v1){
                $scor1[] = $v1['score_id'];
            }
            $scor2 = array_unique($scor1);
            // var_dump($scor2);die;
            foreach($scor2 as $k2 => $v2){
                $res1[$k2]['id'] = $v2;
                $tj['score_id'] = $v2;
                $tj['mtime'] = array('in',$ctime1);
                $tj['ktime'] = $notes['ktime'];
                $detil1[] = M('detail')->where($tj)->select();
            }
            foreach($scor2 as $k2 => $v2){
                foreach($detil1 as $k8 => $v8){
                    foreach($v8 as $k9 => $v9){
                        if($v2 == $v9['score_id']){
                            $res1[$k2]['cha'] += $v9['score'];
                        }
                    }
                }
            }
            foreach($kaohe as $k9 => $v9){
                $kaohe[$k9]['sum'] = 90;
                foreach($res1 as $k7 => $v7){
                    if($v7['id'] == $v9['score_id']){
                        $kaohe[$k9]['sum'] = 90 + $v7['cha'];
                    }
                }
            }
        }else{
            // 计算detail表和entry表中的数据和
            foreach($detail4 as $k1 => $v1){
                $scor1[] = $v1['score_id'];
            }
            $scor2 = array_unique($scor1);
            // var_dump($scor2);die;
            foreach($scor2 as $k2 => $v2){
                $res1[$k2]['id'] = $v2;
                $tj['score_id'] = $v2;
                $tj['mtime'] = array('in',$ctime1);
                $tj['ktime'] = $notes['ktime'];
                $detil1[] = M('detail')->where($tj)->select();
            }
            foreach($scor2 as $k2 => $v2){
                foreach($detil1 as $k8 => $v8){
                    foreach($v8 as $k9 => $v9){
                        if($v2 == $v9['score_id']){
                            $res1[$k2]['cha'] += $v9['score'];
                        }
                    }
                }
            }
            // echo "<pre>";
            // var_dump($res1);
            // echo "</pre>";
            foreach($entry4 as $k4 => $v4){
                $scor3[] = $v4['score_id'];
            }
            $scor4 = array_unique($scor3);
            // var_dump($score4);die;
            foreach($scor4 as $k5 => $v5){
                $res2[$k5]['id'] = $v5;
                $tj1['score_id'] = $v5;
                $tj1['mtime'] = array('in',$ctime2);
                $tj1['ktime'] = $notes['ktime'];
                $etry1[] = M('entry')->where($tj1)->select();
            }
            foreach($scor4 as $k5 => $v5){
                foreach($etry1 as $k6 => $v6){
                    foreach($v6 as $k7 => $v7){
                        if($v5 == $v7['score_id']){
                            $res2[$k5]['cha'] += $v7['score'];
                        }
                    }
                }
            }
            // echo "<pre>";
            // var_dump($res2);
            // echo "</pre>";die;
            $lis = array_merge_recursive($res1,$res2);
            foreach($lis as $key => $val){
                $deen[] = $val['id'];
            }
            $deen1 = array_unique($deen);
            foreach($lis as $key1 => $val1){
                foreach($deen1 as $key2 => $val2){
                    if($val2 == $val1['id']){
                        $li3[$key2]['id'] = $val1['id'];
                        $li3[$key2]['cha'] += $val1['cha'];
                    }
                }
            }
            // echo "<pre>";
            // var_dump($li3);
            // echo "</pre>";die;
            foreach($kaohe as $key3 => $val3){
                $kaohe[$key3]['sum'] = 90;
                foreach($li3 as $key4 => $val4){
                    if($val4['id'] == $val3['score_id']){
                        $kaohe[$key3]['sum'] = 90 + $val4['cha'];
                    }
                }
            }
        }
        // var_dump($kaohe);die;
        foreach($bumen2 as $key12 => $value12){
            foreach($kaohe as $key13 => $value13){
                if($value12 == $value13['team_id']){
                    $pbumen2[$value12] += $value13['sum']; // 各部门总分数
                }
            }
            foreach($pbumen2 as $key14 => $value14){
                foreach($team_name as $key16 => $value16){
                    if($key14 == $key16){
                        $pbumen3[$key14]['team_name'] = $value16;
                    }
                }
                foreach($bumcount as $key15 => $value15){
                    if($key14 == $key15){
                        $pbumen3[$key14]['fen'] = round($value14 / $value15,2);
                    }
                }
            }
        }
        $pbumen4 = $pbumen1 + $pbumen3;
        ksort($pbumen4);
        // echo "<pre>";
        // var_dump($pbumen4);
        // echo "</pre>";die;
        foreach($pbumen4 as $key17 => $value17){
            $pb_name1[] = $value17['team_name'];
            $pb_fen1[] = $value17['fen'];
        }
        $pb_name = implode(',',$pb_name1);
        $pb_fen = implode(',',$pb_fen1);
        // var_dump($pb_name);
        // var_dump($pb_fen);
        // var_dump($month);die;
        $this->assign('team',$team);
        $this->assign('pb_name',$pb_name);
        $this->assign('pb_fen',$pb_fen);
        $this->assign('month',$month);
        $this->display();
    }
}